n = int(input())
A = []
for i in range(n):
    A.append(int(input()))

# list G
m = 0
G = []
G.append(int(1))

while True:
  m += 1
  x = G[m-1]*3 + 1
  if x <= n and m < 100:
      G.append(x)
  else:
      break
G.reverse()

def iSort(A,n,g,cnt):
    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 sSort(A,n,G,m):
    cnt = 0
    for i in range(m):
        cnt = iSort(A,n,G[i],cnt)
    return cnt

print(m)
print(*G)
print(sSort(A,n,G,m))
for i in range(n):
    print(A[i]) n = int(input()) n int(input()) int input() input A = [] A [] for i in range(n):
    A.append(int(input()))

# list G i range(n) range n A.append(int(input())) A.append A append int(input()) int input() input m = 0 m 0 G = [] G [] G.append(int(1)) G.append G append int(1) int 1 while True:
  m += 1
  x = G[m-1]*3 + 1
  if x <= n and m < 100:
      G.append(x)
  else:
      break True m += 1 m 1 x = G[m-1]*3 + 1 x G[m-1]*3 + 1 G[m-1]*3 G[m-1] G m-1 m 1 3 1 if x <= n and m < 100:
      G.append(x)
  else:
      break x <= n and m < 100 x <= n x n m < 100 m 100 G.append(x) G.append G append x break G.reverse() G.reverse G reverse def iSort(A,n,g,cnt):
    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 iSort 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 cnt cnt def sSort(A,n,G,m):
    cnt = 0
    for i in range(m):
        cnt = iSort(A,n,G[i],cnt)
    return cnt sSort cnt = 0 cnt 0 for i in range(m):
        cnt = iSort(A,n,G[i],cnt)
     i range(m) range m cnt = iSort(A,n,G[i],cnt) cnt iSort(A,n,G[i],cnt) iSort A n G[i] G i cnt return cnt cnt A A n n G G m m print(m) print m print(*G) print *G G print(sSort(A,n,G,m)) print sSort(A,n,G,m) sSort A n G m for i in range(n):
    print(A[i]) i range(n) range n print(A[i]) print A[i] A i G = [] [] G def sSort(A,n,G,m):
    cnt = 0
    for i in range(m):
        cnt = iSort(A,n,G[i],cnt)
    return cnt def sSort(A,n,G,m):
    cnt = 0
    for i in range(m):
        cnt = iSort(A,n,G[i],cnt)
    return cnt sSort n = int(input()) int(input()) n def iSort(A,n,g,cnt):
    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 iSort(A,n,g,cnt):
    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 iSort A = [] [] A m = 0 0 m x = G[m-1]*3 + 1 G[m-1]*3 + 1 x m += 1 1 m
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))

# list G
m = 0
G = []
G.append(int(1))

while True:
  m += 1
  x = G[m-1]*3 + 1
  if x <= n and m < 100:
      G.append(x)
  else:
      break
G.reverse()

def iSort(A,n,g,cnt):
    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 sSort(A,n,G,m):
    cnt = 0
    for i in range(m):
        cnt = iSort(A,n,G[i],cnt)
    return cnt

print(m)
print(*G)
print(sSort(A,n,G,m))
for i in range(n):
    print(A[i])
