Conventions

A, An, B, and C are 0 or [A0,A1,...,Ak] for some natural k.
X and Xn are empty or A0,A1,...,Ak for some natural k.
L and Ln are empty or A0,A1,...,Ak for some natural k.
n$A$B = (n$A)$B; $ is left-associative.
Strings in {} are always repeated n times.

Helper functions

T(A)

Define T(A) like so:
  1. T(0) = 0.
  2. T([0]) = 1.
  3. Let A = [A0,X].
    T(A) = T(A0).

P(A)

Define P(A) like so:
  1. P(0) is undefined.
  2. P([0]) = 1.
  3. Otherwise, let A = [A0,X].
    P(A) = [P(A0),X].

Definition

We start with n$A for some A, and natural n. This solves into the "result".
  1. A = 0. Then, result is 10n.
  2. Value of T(A)?
    1. 0: Jump to 3.
    2. 1: Result is 1 {$P(A)}.
  3. Look at the first entry of A. Assume the array you are currently looking at is B.
    Is the entry you are currently looking at 0?
    1. Yes: Go to next entry
    2. No: Value of T(B)?
      1. 0: Look at the first entry of B. Jump to 3.
      2. 1: Jump to 4.
  4. Let C = [L,0,B,X], where C is the smallest array that B is contained in that is in A.
    Then, replace C with [L, {[} 0 {,P(B),X]} ,P(B),X] in A. Call this new array A'.
    The result is 1$A'.