import scala.io.StdIn.{readLong, readInt}
object Main {
    def main(args: Array[String]): Unit = {
        val len = readInt
        val arr = (1 to len).toArray.map(a => readLong)
        println(shellSort(arr, len).mkString("\n"))
    }
    
    def shellSort(arr: Array[Long], len: Int): Array[Long] = {
        val copy = new Array[Long](len)
        arr.copyToArray(copy)
        var cnt = 0
        val groups = genGroups(len).reverse
        println(groups.length + "\n" + groups.mkString(" "))
        groups.foreach { g => 
            (0 until g).foreach { start => 
                cnt += insertionSort(copy, start, len, g)
            }
        } 
        println(cnt)
        copy
    }
    
    def insertionSort(arr: Array[Long], start: Int, len: Int, group: Int): Int = {
        var cnt = 0
         Range(start, len, group).foreach { targetIndex => 
             val target = arr(targetIndex)
             Range(start, targetIndex, group).reverse.find { insertIndex =>
                 if (arr(insertIndex) > target) {
                     arr(insertIndex + group) = arr(insertIndex)
                     arr(insertIndex) = target
                     cnt += 1
                     false
                 } else {
                     true
                 }
             }
         }
        cnt
    }
    
    def genGroups(len: Int): List[Int] =  {
        def go(len: Int, glen: Int, next: Int): List[Int] = next match {
            case a if (a == 1) || (a < len && glen < len) => a :: go(len, glen + 1, a * 3 + 1)
            case a => Nil
        }
        go(len, 0, 1)
    }
}
