def insertionSort(a,n,g)
  cnt = 0
  for i in g..n-1
    v = a[i]
    j = i-g
    while j>=0 && a[j]>v do
      a[j+g] = a[j]
      j = j-g
      cnt += 1
    end
    a[j+g] = v
  end
  return cnt
end
 
def makeShellNum(n)
  num = 0
  arr = []
  tmp = 1
  while n >= tmp do
    arr << tmp
    num += 1
    tmp = 3*tmp + 1
  end
  return num,arr.reverse
end

def shellSort(a,n)
  cnt = 0
  m,g = makeShellNum(n)
  for i in 0..m-1
    cnt += insertionSort(a,n,g[i])
  end
  printf("%d\n%s\n%d\n%s\n",m,g.join(" "),cnt,a.join("\n"))
end

n = gets.chomp.to_i
a = []
for i in 1..n do
  a[i-1] = gets.chomp.to_i
end
shellSort(a,n)
