import sys
import math
import copy
from typing import Tuple, List
input = sys.stdin.readline

def swap (A: List, i: int, j: int) -> None:
    temp = A [i]
    A [i] = A [j]
    A [j] = temp


def insertionSort(A, n, g):
    cnt = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
    return cnt

def shellSort(A, n):
    cnt = 0
    g = []
    h = 1
    while h <= len(A):
        g.append(h)
        h = 3 * h + 1
    g.reverse()
    m = len(g)
    print(m)
    print(" ".join(map(str, g)))
    for i in range(m):
        cnt += insertionSort(A, n, g[i])
    print(cnt)


if __name__ == "__main__":
    n = int(input())
    A = []
    for i in range(n):
        A.append(int(input()))
    shellSort(A, len(A))
    for item in A:
        print(item)
 import sys sys import math math import copy copy from typing import Tuple, List input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def swap (A: List, i: int, j: int) -> None:
    temp = A [i]
    A [i] = A [j]
    A [j] = temp swap temp = A [i] temp A [i] A i A [i] = A [j] A [i] A i A [j] A j A [j] = temp A [j] A j temp A: List A i: int i j: int j def insertionSort(A, n, g):
    cnt = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
    return cnt insertionSort cnt = 0 cnt 0 for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
     i range(g, n) range g n v = A[i] v A[i] A i j = i - g j i - g i g while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
         j >= 0 and A[j] > v j >= 0 j 0 A[j] > v A[j] A j v A[j + g] = A[j] A[j + g] A j + g j g A[j] A j j = j - g j j - g j g cnt += 1 cnt 1 A[j + g] = v A[j + g] A j + g j g v return cnt cnt A A n n g g def shellSort(A, n):
    cnt = 0
    g = []
    h = 1
    while h <= len(A):
        g.append(h)
        h = 3 * h + 1
    g.reverse()
    m = len(g)
    print(m)
    print(" ".join(map(str, g)))
    for i in range(m):
        cnt += insertionSort(A, n, g[i])
    print(cnt) shellSort cnt = 0 cnt 0 g = [] g [] h = 1 h 1 while h <= len(A):
        g.append(h)
        h = 3 * h + 1
     h <= len(A) h len(A) len A g.append(h) g.append g append h h = 3 * h + 1 h 3 * h + 1 3 * h 3 h 1 g.reverse() g.reverse g reverse m = len(g) m len(g) len g print(m) print m print(" ".join(map(str, g))) print " ".join(map(str, g)) " ".join " " join map(str, g) map str g for i in range(m):
        cnt += insertionSort(A, n, g[i])
     i range(m) range m cnt += insertionSort(A, n, g[i]) cnt insertionSort(A, n, g[i]) insertionSort A n g[i] g i print(cnt) print cnt A A n n if __name__ == "__main__":
    n = int(input())
    A = []
    for i in range(n):
        A.append(int(input()))
    shellSort(A, len(A))
    for item in A:
        print(item) __name__ == "__main__" __name__ "__main__" n = int(input()) n int(input()) int input() input A = [] A [] for i in range(n):
        A.append(int(input()))
     i range(n) range n A.append(int(input())) A.append A append int(input()) int input() input shellSort(A, len(A)) shellSort A len(A) len A for item in A:
        print(item) item A print(item) print item input = sys.stdin.readline sys.stdin.readline input def insertionSort(A, n, g):
    cnt = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
    return cnt def insertionSort(A, n, g):
    cnt = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
    return cnt insertionSort def shellSort(A, n):
    cnt = 0
    g = []
    h = 1
    while h <= len(A):
        g.append(h)
        h = 3 * h + 1
    g.reverse()
    m = len(g)
    print(m)
    print(" ".join(map(str, g)))
    for i in range(m):
        cnt += insertionSort(A, n, g[i])
    print(cnt) def shellSort(A, n):
    cnt = 0
    g = []
    h = 1
    while h <= len(A):
        g.append(h)
        h = 3 * h + 1
    g.reverse()
    m = len(g)
    print(m)
    print(" ".join(map(str, g)))
    for i in range(m):
        cnt += insertionSort(A, n, g[i])
    print(cnt) shellSort n = int(input()) int(input()) n A = [] [] A def swap (A: List, i: int, j: int) -> None:
    temp = A [i]
    A [i] = A [j]
    A [j] = temp def swap (A: List, i: int, j: int) -> None:
    temp = A [i]
    A [i] = A [j]
    A [j] = temp swap
import sys
import math
import copy
from typing import Tuple, List
input = sys.stdin.readline

def swap (A: List, i: int, j: int) -> None:
    temp = A [i]
    A [i] = A [j]
    A [j] = temp


def insertionSort(A, n, g):
    cnt = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
    return cnt

def shellSort(A, n):
    cnt = 0
    g = []
    h = 1
    while h <= len(A):
        g.append(h)
        h = 3 * h + 1
    g.reverse()
    m = len(g)
    print(m)
    print(" ".join(map(str, g)))
    for i in range(m):
        cnt += insertionSort(A, n, g[i])
    print(cnt)


if __name__ == "__main__":
    n = int(input())
    A = []
    for i in range(n):
        A.append(int(input()))
    shellSort(A, len(A))
    for item in A:
        print(item)

