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

def insertionSort(A, n, g):
 global 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 -= g
   cnt +=1
  A[j + g] = v

def shellSort(A, n, m, G):
 A1 = A[:]
 global cnt
 cnt = 0
 for i in range(m):
  insertionSort(A1, n, G[i])
 return A1

def Gmake(n):
 G=[]
 k = 1
 while k <= n and len(G) < 100:
  G.append(k)
  k = 3 * k + 1
 G.reverse()
 return G

G = Gmake(n)
A2 = shellSort(A, n, len(G), G)
print(str(len(G)))
print(" ".join(map(str, G)))
print(str(cnt))
for i in A2:
 print(str(i)) n = int(input()) n int(input()) int input() input int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input A = [int(input()) for i in range(n)] A [int(input()) for i in range(n)] def insertionSort(A, n, g):
 global 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 -= g
   cnt +=1
  A[j + g] = v insertionSort global 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 -= 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 -= 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 -= g j g cnt +=1 cnt 1 A[j + g] = v A[j + g] A j + g j g v A A n n g g def shellSort(A, n, m, G):
 A1 = A[:]
 global cnt
 cnt = 0
 for i in range(m):
  insertionSort(A1, n, G[i])
 return A1 shellSort A1 = A[:] A1 A[:] A : global cnt cnt = 0 cnt 0 for i in range(m):
  insertionSort(A1, n, G[i])
  i range(m) range m insertionSort(A1, n, G[i]) insertionSort A1 n G[i] G i return A1 A1 A A n n m m G G def Gmake(n):
 G=[]
 k = 1
 while k <= n and len(G) < 100:
  G.append(k)
  k = 3 * k + 1
 G.reverse()
 return G Gmake G=[] G [] k = 1 k 1 while k <= n and len(G) < 100:
  G.append(k)
  k = 3 * k + 1
  k <= n and len(G) < 100 k <= n k n len(G) < 100 len(G) len G 100 G.append(k) G.append G append k k = 3 * k + 1 k 3 * k + 1 3 * k 3 k 1 G.reverse() G.reverse G reverse return G G n n G = Gmake(n) G Gmake(n) Gmake n A2 = shellSort(A, n, len(G), G) A2 shellSort(A, n, len(G), G) shellSort A n len(G) len G G print(str(len(G))) print str(len(G)) str len(G) len G print(" ".join(map(str, G))) print " ".join(map(str, G)) " ".join " " join map(str, G) map str G print(str(cnt)) print str(cnt) str cnt for i in A2:
 print(str(i)) i A2 print(str(i)) print str(i) str i def shellSort(A, n, m, G):
 A1 = A[:]
 global cnt
 cnt = 0
 for i in range(m):
  insertionSort(A1, n, G[i])
 return A1 def shellSort(A, n, m, G):
 A1 = A[:]
 global cnt
 cnt = 0
 for i in range(m):
  insertionSort(A1, n, G[i])
 return A1 shellSort A = [int(input()) for i in range(n)] [int(input()) for i in range(n)] A G = Gmake(n) Gmake(n) G def insertionSort(A, n, g):
 global 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 -= g
   cnt +=1
  A[j + g] = v def insertionSort(A, n, g):
 global 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 -= g
   cnt +=1
  A[j + g] = v insertionSort A2 = shellSort(A, n, len(G), G) shellSort(A, n, len(G), G) A2 def Gmake(n):
 G=[]
 k = 1
 while k <= n and len(G) < 100:
  G.append(k)
  k = 3 * k + 1
 G.reverse()
 return G def Gmake(n):
 G=[]
 k = 1
 while k <= n and len(G) < 100:
  G.append(k)
  k = 3 * k + 1
 G.reverse()
 return G Gmake n = int(input()) int(input()) n
n = int(input())
A = [int(input()) for i in range(n)]

def insertionSort(A, n, g):
 global 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 -= g
   cnt +=1
  A[j + g] = v

def shellSort(A, n, m, G):
 A1 = A[:]
 global cnt
 cnt = 0
 for i in range(m):
  insertionSort(A1, n, G[i])
 return A1

def Gmake(n):
 G=[]
 k = 1
 while k <= n and len(G) < 100:
  G.append(k)
  k = 3 * k + 1
 G.reverse()
 return G

G = Gmake(n)
A2 = shellSort(A, n, len(G), G)
print(str(len(G)))
print(" ".join(map(str, G)))
print(str(cnt))
for i in A2:
 print(str(i))