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): (Seq[Long], Long) = {
      (g until n)
        .foldLeft((seq, 0l)) { (t, i) =>
          val (nextSeq, cnt) = t._1.swapEachG(i, g)
          (nextSeq, cnt + t._2)
        }
    }

    def swapEachG(i: Int, g: Int): (Seq[Long], Long) = {
      val v = seq(i)

      def jStream(j: Int): Stream[Int] = Stream.cons(j, jStream(j - g))

      val jSeq = jStream(i - g).takeWhile(idx => idx >= 0 && seq(idx) > v).toList
      if (jSeq.isEmpty) return (seq, 0)

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

    def recuresiveLoop(G: Seq[Int]): (Seq[Long], Long) = {
      G.foldLeft((seq, 0l)) { (t, g) =>
        val (nextSeq, cnt) = t._1.insertionSort(t._1.length, g)
        (nextSeq, t._2 + cnt)
      }
    }

    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)
      (retSeq, G, cnt)
    }
  }
}

