def shell_sort(arr, gaps)
  n = arr.size

  h = 1

  loop do
    break if h > n
    gaps.unshift(h)
    h = 3 * h + 1
  end

  count = 0

  gaps.each do |gap|
    count += insertion_sort(arr, gap)
  end

  count
end

def insertion_sort(arr, gap)
  count = 0

  gap.upto(arr.size - 1) do |i|
    temp = arr[i]
    j = i - gap

    while j >= 0 && arr[j] > temp
      arr[j + gap] = arr[j]
      j -= gap
      count += 1
    end

    arr[j + gap] = temp
  end

  count
end

n = gets.to_i

arr = $stdin.read.split.map(&:to_i)

gaps = []

count = shell_sort(arr, gaps)

puts gaps.size
puts gaps.join(' ')
puts count
puts arr