#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
ALDS1_2-D

Sort I - Shell Sort

=end

class Sort
  def initialize(f)
    @cnt=0
    @n=f.length
    @a = Array.new(@n,0)
    0.upto(@n).each{|i| @a[i] = f[i]}
  end

  def insertionSort(g)
    g.upto(@n-1){|i|
      v = @a[i]
      j = i - g
      while j >= 0 and @a[j] > v do
        @a[j+g] = @a[j]
        j = j - g
        @cnt +=1
        @a[j+g] = v
      end
    }
  end

  def shellSort()
    g = [121, 40, 13, 4, 1]
    m = g.length
    puts m
    puts g.map{|x| x.to_s}.join(" ")

    0.upto(m-1) {|i|
      insertionSort(g[i])
    }
    puts @cnt
    @a
  end

end

class Main
  def initialize()
    #fh = open("x.txt")
    fh = STDIN
    n = fh.gets.chomp.to_i
    f = Array.new(n,0)
    0.upto(n-1).each{|i|
      f[i] = fh.gets.chomp.to_i }

    abort if f.length != n
    st = Sort.new(f)
    g = st.shellSort()
    g.each{|x| puts x.to_s}

  end
end

if $0==__FILE__ then
  Main.new()
end