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

  implicit class RichSeqLong(seq: Seq[Long]) {
    def insertionSort(n: Int, g: Int)(idx: Int = g, cnt: Long = 0): (Seq[Long], Long) = {
      if (idx == n) {
        (seq, cnt)
      } else {
        val (nextSeq, thisCnt) = seq.swapEachG(g, seq(idx))(idx - g)
        nextSeq.insertionSort(n, g)(idx + 1, cnt + thisCnt)
      }
    }

    def swapEachG(g: Int, v: Long)(j: Int, cnt: Long = 0): (Seq[Long], Long) = {
      if (j < 0 || seq(j) <= v) (seq.updated(j + g, v), cnt)
      else seq.updated(j + g, seq(j)).swapEachG(g, v)(j - g, cnt + 1)
    }

    def recuresiveLoop(G:Seq[Int], cnt:Long): (Seq[Long], Long) = {
      G match {
        case Nil => (seq, cnt)
        case h +: tail => {
          val (nextSeq, thisCnt) = seq.insertionSort(seq.length, h)()
          nextSeq.recuresiveLoop(tail, cnt+thisCnt)
        }
      }
    }

    def shellSort(): (Seq[Long], Seq[Int], Long) = {
      val n = seq.length
      def genG(n : Long) = Stream.cons(n, Stream(3*n+1))
      val G: Seq[Int] = genG(1).takeWhile(_ <= n).map(_.asInstanceOf[Int]).toList.reverse
      val (retSeq, cnt) = seq.recuresiveLoop(G, 0)
      (retSeq, G, cnt)
    }
  }
}

