require 'pp'

def insertion_sort(g)
  g.upto(@n-1).each do |i|
    v = @a[i]
    j = i - g
    while j >= 0 && @a[j] > v
      @a[j+g] = @a[j]
      j = j - g
      @cnt += 1
    end
    @a[j+g] = v
  end
end

def shell_sort
  @g = init_g
  0.upto(@g.length-1).each{ |i| insertion_sort(@g[i]) }
end

def init_g
  acc = []
  i = 1
  loop do
    break if i > @n
    acc << i
    i = 3*i+1
  end
  acc.reverse
end

@n = gets.to_i
@cnt = 0
@a = []
@g = []
@n.times do
  @a << gets.to_i
end

shell_sort

puts @g.length
puts @g.join(' ')
puts @cnt
puts @a

