object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)

    val n = scanner.nextInt
    val A = Array.fill(n)(scanner.nextInt)

    val r = shellSort(A, n)
    val G = r._1
    val cnt = r._2
    println(G.length)
    println(G.mkString(" "))
    println(cnt)
    A.foreach(println)
  }

  def insertionSort(A: Array[Int], n: Int, g: Int): Int = {
    var c = 0
    for(i <- g until n) {
      val v = A(i)
      var j = i - g
      while(j >= 0 && A(j) > v) {
        A(j + g) = A(j)
        j = j - g
        c = c + 1
      }
      A(j + g) = v
    }
    c
  }

  def shellSort(A: Array[Int], n: Int): (Seq[Int], Int) = {
    def f(hi: Int, n: Int): List[Int] = {
      val m = hi * 3 + 1
      if(m > n) List(hi) else hi :: f(m, n)
    }

    val G = f(1, n).reverse
    (G, G.map(insertionSort(A, n, _)).sum)
  }
}

