N = gets.to_i
A = N.times.map{gets.to_i}
cnt = 0

def fibo(n)
  f = [1, 1]
  i = 1
  while f[i-1] + f[i] < n
    f << f[i-1] + f[i]
    i += 1
  end
  f[1..-1].reverse
end

insertion = ->(a, g = 1) do
  g.step(N-1) do |i|
    v = a[i]
    j = i - g
    while j >= 0 && a[j] > v
      a[j+g] = a[j]
      j -= g
      cnt += 1
    end
    a[j+g] = v
  end
  a
end

shell = ->(a) do
  cnt = 0
  g = fibo(N)
  puts g.size
  puts g.join ' '
  g.each do |i|
    a = insertion.(a, i)
  end
  puts cnt
  a
end

shell.(A.dup).each do |d|
  puts d
end

