def insertionsort(a, n, g):
    cnt = 0
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j = j - g
            cnt += 1
        a[j + g] = v
    return cnt


def shellsort(a, n):
    g = []
    gap = 1
    while gap <= n:
        g.append(gap)
        gap = 3 * gap + 1
    g = g[::-1]
    m = len(g)
    print(m)
    print(*g)
    cnt = 0
    for i in range(m):
        cnt += insertionsort(a, n, g[i])
    print(cnt)

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
shellsort(a, n)
print("\n".join(map(str, a))) def insertionsort(a, n, g):
    cnt = 0
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j = j - g
            cnt += 1
        a[j + g] = v
    return cnt insertionsort cnt = 0 cnt 0 for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j = j - g
            cnt += 1
        a[j + g] = v
     i range(g, n) range g n v = a[i] v a[i] a i j = i - g j i - g i g while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j = j - g
            cnt += 1
         j >= 0 and a[j] > v j >= 0 j 0 a[j] > v a[j] a j v a[j + g] = a[j] a[j + g] a j + g j g a[j] a j j = j - g j j - g j g cnt += 1 cnt 1 a[j + g] = v a[j + g] a j + g j g v return cnt cnt a a n n g g def shellsort(a, n):
    g = []
    gap = 1
    while gap <= n:
        g.append(gap)
        gap = 3 * gap + 1
    g = g[::-1]
    m = len(g)
    print(m)
    print(*g)
    cnt = 0
    for i in range(m):
        cnt += insertionsort(a, n, g[i])
    print(cnt) shellsort g = [] g [] gap = 1 gap 1 while gap <= n:
        g.append(gap)
        gap = 3 * gap + 1
     gap <= n gap n g.append(gap) g.append g append gap gap = 3 * gap + 1 gap 3 * gap + 1 3 * gap 3 gap 1 g = g[::-1] g g[::-1] g ::-1 -1 m = len(g) m len(g) len g print(m) print m print(*g) print *g g cnt = 0 cnt 0 for i in range(m):
        cnt += insertionsort(a, n, g[i])
     i range(m) range m cnt += insertionsort(a, n, g[i]) cnt insertionsort(a, n, g[i]) insertionsort a n g[i] g i print(cnt) print cnt a a n n n = int(input()) n int(input()) int input() input a = [] a [] for i in range(n):
    a.append(int(input())) i range(n) range n a.append(int(input())) a.append a append int(input()) int input() input shellsort(a, n) shellsort a n print("\n".join(map(str, a))) print "\n".join(map(str, a)) "\n".join "\n" join map(str, a) map str a n = int(input()) int(input()) n def shellsort(a, n):
    g = []
    gap = 1
    while gap <= n:
        g.append(gap)
        gap = 3 * gap + 1
    g = g[::-1]
    m = len(g)
    print(m)
    print(*g)
    cnt = 0
    for i in range(m):
        cnt += insertionsort(a, n, g[i])
    print(cnt) def shellsort(a, n):
    g = []
    gap = 1
    while gap <= n:
        g.append(gap)
        gap = 3 * gap + 1
    g = g[::-1]
    m = len(g)
    print(m)
    print(*g)
    cnt = 0
    for i in range(m):
        cnt += insertionsort(a, n, g[i])
    print(cnt) shellsort a = [] [] a def insertionsort(a, n, g):
    cnt = 0
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j = j - g
            cnt += 1
        a[j + g] = v
    return cnt def insertionsort(a, n, g):
    cnt = 0
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j = j - g
            cnt += 1
        a[j + g] = v
    return cnt insertionsort
def insertionsort(a, n, g):
    cnt = 0
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j = j - g
            cnt += 1
        a[j + g] = v
    return cnt


def shellsort(a, n):
    g = []
    gap = 1
    while gap <= n:
        g.append(gap)
        gap = 3 * gap + 1
    g = g[::-1]
    m = len(g)
    print(m)
    print(*g)
    cnt = 0
    for i in range(m):
        cnt += insertionsort(a, n, g[i])
    print(cnt)

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
shellsort(a, n)
print("\n".join(map(str, a)))