# -*- coding: utf-8 -*-

N = int(raw_input())
A = []
for i in range(N):
    A.append(int(raw_input()))
cnt = 0
G = [1]
while G[-1]*3+1 < N:
    G.append(G[-1]*3+1)
G.reverse()
m = len(G)
for i in range(m):
    g = G[i]
    for j in range(g, N):
        v = A[j]
        k = j-g
        while k >= 0 and A[k] > v:
            A[k+g] = A[k]
            k -= g
            cnt += 1
        A[k+g] = v
print m
print " ".join(map(str, G))
print cnt
for i in range(N):
    print A[i] N = int(raw_input()) N int(raw_input()) int raw_input() raw_input A = [] A [] for i in range(N):
    A.append(int(raw_input())) i range(N) range N A.append(int(raw_input())) A.append A append int(raw_input()) int raw_input() raw_input cnt = 0 cnt 0 G = [1] G [1] 1 while G[-1]*3+1 < N:
    G.append(G[-1]*3+1) G[-1]*3+1 < N G[-1]*3+1 G[-1]*3 G[-1] G -1 3 1 N G.append(G[-1]*3+1) G.append G append G[-1]*3+1 G[-1]*3 G[-1] G -1 3 1 G.reverse() G.reverse G reverse m = len(G) m len(G) len G for i in range(m):
    g = G[i]
    for j in range(g, N):
        v = A[j]
        k = j-g
        while k >= 0 and A[k] > v:
            A[k+g] = A[k]
            k -= g
            cnt += 1
        A[k+g] = v i range(m) range m g = G[i] g G[i] G i for j in range(g, N):
        v = A[j]
        k = j-g
        while k >= 0 and A[k] > v:
            A[k+g] = A[k]
            k -= g
            cnt += 1
        A[k+g] = v j range(g, N) range g N v = A[j] v A[j] A j k = j-g k j-g j g while k >= 0 and A[k] > v:
            A[k+g] = A[k]
            k -= g
            cnt += 1
         k >= 0 and A[k] > v k >= 0 k 0 A[k] > v A[k] A k v A[k+g] = A[k] A[k+g] A k+g k g A[k] A k k -= g k g cnt += 1 cnt 1 A[k+g] = v A[k+g] A k+g k g v print print " ".join(map(str, G)) " ".join " " join map(str, G) map str G print for i in range(N):
    print A[i] i range(N) range N print A[i] A i k = j-g j-g k m = len(G) len(G) m k -= g g k cnt += 1 1 cnt N = int(raw_input()) int(raw_input()) N A = [] [] A cnt = 0 0 cnt v = A[j] A[j] v G = [1] [1] G g = G[i] G[i] g
# -*- coding: utf-8 -*-

N = int(raw_input())
A = []
for i in range(N):
    A.append(int(raw_input()))
cnt = 0
G = [1]
while G[-1]*3+1 < N:
    G.append(G[-1]*3+1)
G.reverse()
m = len(G)
for i in range(m):
    g = G[i]
    for j in range(g, N):
        v = A[j]
        k = j-g
        while k >= 0 and A[k] > v:
            A[k+g] = A[k]
            k -= g
            cnt += 1
        A[k+g] = v
print m
print " ".join(map(str, G))
print cnt
for i in range(N):
    print A[i]