import scala.collection.mutable
import scala.collection.mutable.ArraySeq
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt
    val seq: mutable.ArraySeq[Long] = mutable.ArraySeq.fill(n)(sc.nextLong)
    val (retSeq, g, cnt) = seq.shellSort()

    println(g.length)
    println(g.mkString(" "))
    println(cnt)
    retSeq.foreach(println)
  }

  implicit class RichSeqLong(seq: ArraySeq[Long]) {
    def insertionSort(n: Int, g: Int): Int = {

      var b_cnt = 0
      for (i <- g until n){
        val v = seq(i)
        val jSeq = {for (j <- i - g to 0 by -g) yield j}.takeWhile(seq(_) > v)
        jSeq.foreach(j => seq.update(j + g, seq(j)))
        if (jSeq.nonEmpty) seq.update(jSeq.last, v)
        b_cnt += jSeq.length
      }

      b_cnt
    }

    def recuresiveLoop(G: Seq[Int], n: Int): (ArraySeq[Long], Long) = {
      val cnt = G.foldLeft(0) {(i, g) => i + seq.insertionSort(n, g)}
      (seq, cnt)
    }

    def shellSort(): (ArraySeq[Long], Seq[Int], Long) = {
      val n = seq.length

      def genG(n: Long): Stream[Long] = Stream.cons(n, genG(3 * n + 1))

      val G: Seq[Int] = genG(1)
                        .takeWhile(_ <= n)
                        .map(_.asInstanceOf[Int])
                        .toList
                        .reverse

      val (retSeq, cnt) = seq.recuresiveLoop(G, n)

      (retSeq, G, cnt)
    }
  }
}
