import math

N = int(input())
A = list(int(input()) for _ in range(N))

def insertionSort(A,n,g,cnt):
    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 = []
    bet = 0
    while True:
        bet = 3*bet + 1
        if bet <= n:
            G.insert(0,bet)
        else:
            break
    m = len(G)

    for i in range(m):
        cnt = insertionSort(A,n,G[i],cnt)
    print(m)
    outputNumList(G)
    print(cnt)

def outputNumList(A):
    tmp = map(str,A)
    text = " ".join(tmp)
    print(text)

shellSort(A,N)
for k in range(N):
    print(A[k]) import math math N = int(input()) N int(input()) int input() input A = list(int(input()) for _ in range(N)) A list(int(input()) for _ in range(N)) list int(input()) int input() input def insertionSort(A,n,g,cnt):
    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 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 cnt cnt def shellSort(A,n):
    cnt = 0
    G = []
    bet = 0
    while True:
        bet = 3*bet + 1
        if bet <= n:
            G.insert(0,bet)
        else:
            break
    m = len(G)

    for i in range(m):
        cnt = insertionSort(A,n,G[i],cnt)
    print(m)
    outputNumList(G)
    print(cnt) shellSort cnt = 0 cnt 0 G = [] G [] bet = 0 bet 0 while True:
        bet = 3*bet + 1
        if bet <= n:
            G.insert(0,bet)
        else:
            break
     True bet = 3*bet + 1 bet 3*bet + 1 3*bet 3 bet 1 if bet <= n:
            G.insert(0,bet)
        else:
            break
     bet <= n bet n G.insert(0,bet) G.insert G insert 0 bet break m = len(G) m len(G) len G for i in range(m):
        cnt = insertionSort(A,n,G[i],cnt)
     i range(m) range m cnt = insertionSort(A,n,G[i],cnt) cnt insertionSort(A,n,G[i],cnt) insertionSort A n G[i] G i cnt print(m) print m outputNumList(G) outputNumList G print(cnt) print cnt A A n n def outputNumList(A):
    tmp = map(str,A)
    text = " ".join(tmp)
    print(text) outputNumList tmp = map(str,A) tmp map(str,A) map str A text = " ".join(tmp) text " ".join(tmp) " ".join " " join tmp print(text) print text A A shellSort(A,N) shellSort A N for k in range(N):
    print(A[k]) k range(N) range N print(A[k]) print A[k] A k A = list(int(input()) for _ in range(N)) list(int(input()) for _ in range(N)) A def shellSort(A,n):
    cnt = 0
    G = []
    bet = 0
    while True:
        bet = 3*bet + 1
        if bet <= n:
            G.insert(0,bet)
        else:
            break
    m = len(G)

    for i in range(m):
        cnt = insertionSort(A,n,G[i],cnt)
    print(m)
    outputNumList(G)
    print(cnt) def shellSort(A,n):
    cnt = 0
    G = []
    bet = 0
    while True:
        bet = 3*bet + 1
        if bet <= n:
            G.insert(0,bet)
        else:
            break
    m = len(G)

    for i in range(m):
        cnt = insertionSort(A,n,G[i],cnt)
    print(m)
    outputNumList(G)
    print(cnt) shellSort def insertionSort(A,n,g,cnt):
    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):
    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 N = int(input()) int(input()) N def outputNumList(A):
    tmp = map(str,A)
    text = " ".join(tmp)
    print(text) def outputNumList(A):
    tmp = map(str,A)
    text = " ".join(tmp)
    print(text) outputNumList
import math

N = int(input())
A = list(int(input()) for _ in range(N))

def insertionSort(A,n,g,cnt):
    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 = []
    bet = 0
    while True:
        bet = 3*bet + 1
        if bet <= n:
            G.insert(0,bet)
        else:
            break
    m = len(G)

    for i in range(m):
        cnt = insertionSort(A,n,G[i],cnt)
    print(m)
    outputNumList(G)
    print(cnt)

def outputNumList(A):
    tmp = map(str,A)
    text = " ".join(tmp)
    print(text)

shellSort(A,N)
for k in range(N):
    print(A[k])
