@cnt = 0

def g(i)
  @g ||= [1]

  if v = @g[i]
    return v
  end

  @g[i] = @g[i-1] + 3 ** i
end

# 1  insertionSort(A, n, g)
# 2      for i = g to n-1
# 3          v = A[i]
# 4          j = i - g
# 5          while j >= 0 && A[j] > v
# 6              A[j+g] = A[j]
# 7              j = j - g
# 8              cnt++
# 9          A[j+g] = v
def insertion_sort(a, gi)
  n = a.length
  for i in gi..(n-1)
    v = a[i]
    j = i - gi
    while j >= 0 && a[j] > v
      a[j+gi] = a[j]
      j = j - gi
      @cnt += 1
    end
    a[j+gi] = v
  end
end

#  shellSort(A, n)
#     cnt = 0
#     m = ?
#     G[] = {?, ?,..., ?}
#     for i = 0 to m-1
#         insertionSort(A, n, G[i])
def shell_sort(a)
  m = 0
  while a.length > g(m)
    m += 1
  end

  for i in [*0..m].reverse
    insertion_sort(a, g(i))
  end

  [m, @cnt, a]
end

n = gets.to_i
a = n.times.map{gets.to_i}

m, cnt, a = shell_sort(a)

m = 1 if m == 0

puts m
puts (0...m).map{|i|g(i)}.reverse.join(" ")
puts cnt
puts a

