object Main {
  def main(args: Array[String]): Unit = {
    val n = scala.io.StdIn.readInt()
    val seq: IndexedSeq[Long] = {for (i <- 1 to n) yield scala.io.StdIn.readLong()}
    val (retSeq, g, cnt) = seq.shellSort()

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

  implicit class RichSeqLong(seq: IndexedSeq[Long]) {
    def insertionSort(prevCnt: Long, n: Int, g: Int): (IndexedSeq[Long], Long) = {
      (g until n).foldLeft((seq, prevCnt)) { (t, i) => t._1.swapEachG(t._2, i, g) }
    }

    def swapEachG(prevCnt: Long, i: Int, g: Int): (IndexedSeq[Long], Long) = {

      val v = seq(i)
      val jSeq = {for (j <- i - g to 0 by -g) yield j}.takeWhile(j => seq(j) > v)

      if (jSeq.isEmpty) return (seq, prevCnt)

      val (retSeq, cnt): (IndexedSeq[Long], Long) =
        jSeq.foldLeft((seq, 0l)) { (t, j) => (t._1.updated(j + g, t._1(j)), t._2 + 1) }

      (retSeq.updated(jSeq.last, v), cnt + prevCnt)
    }

    def recuresiveLoop(G: Seq[Int], n: Int): (IndexedSeq[Long], Long) = {
      G.foldLeft((seq, 0l)) { (t, g) => t._1.insertionSort(t._2, n, g) }
    }

    def shellSort(): (Seq[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)
    }
  }
}
