n = int(input())
arr = [int(input()) for _ in range(n)] 

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

def shellSort(arr, n):
    G = []
    g = 1
    cnt = 0
    while g < n or g == 1:
        G.append(g)
        g = 3*g + 1
    G = G[::-1]
    print(len(G))
    for i in range(len(G)):
        cnt += insertionSort(arr, n, G[i])
    print(*G)
    print(cnt)
    for a in arr:
        print(a)

shellSort(arr, n) n = int(input()) n int(input()) int input() input int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input arr = [int(input()) for _ in range(n)] arr [int(input()) for _ in range(n)] def insertionSort(arr, n, g):
    cnt = 0
    for i in range(g, n):
        key = arr[i]
        j = i - g
        while j >= 0 and arr[j] > key:
            arr[j + g] = arr[j]
            j -= g
            cnt += 1
        arr[j + g] = key
    return cnt insertionSort cnt = 0 cnt 0 for i in range(g, n):
        key = arr[i]
        j = i - g
        while j >= 0 and arr[j] > key:
            arr[j + g] = arr[j]
            j -= g
            cnt += 1
        arr[j + g] = key
     i range(g, n) range g n key = arr[i] key arr[i] arr i j = i - g j i - g i g while j >= 0 and arr[j] > key:
            arr[j + g] = arr[j]
            j -= g
            cnt += 1
         j >= 0 and arr[j] > key j >= 0 j 0 arr[j] > key arr[j] arr j key arr[j + g] = arr[j] arr[j + g] arr j + g j g arr[j] arr j j -= g j g cnt += 1 cnt 1 arr[j + g] = key arr[j + g] arr j + g j g key return cnt cnt arr arr n n g g def shellSort(arr, n):
    G = []
    g = 1
    cnt = 0
    while g < n or g == 1:
        G.append(g)
        g = 3*g + 1
    G = G[::-1]
    print(len(G))
    for i in range(len(G)):
        cnt += insertionSort(arr, n, G[i])
    print(*G)
    print(cnt)
    for a in arr:
        print(a) shellSort G = [] G [] g = 1 g 1 cnt = 0 cnt 0 while g < n or g == 1:
        G.append(g)
        g = 3*g + 1
     g < n or g == 1 g < n g n g == 1 g 1 G.append(g) G.append G append g g = 3*g + 1 g 3*g + 1 3*g 3 g 1 G = G[::-1] G G[::-1] G ::-1 -1 print(len(G)) print len(G) len G for i in range(len(G)):
        cnt += insertionSort(arr, n, G[i])
     i range(len(G)) range len(G) len G cnt += insertionSort(arr, n, G[i]) cnt insertionSort(arr, n, G[i]) insertionSort arr n G[i] G i print(*G) print *G G print(cnt) print cnt for a in arr:
        print(a) a arr print(a) print a arr arr n n shellSort(arr, n) shellSort arr n arr = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] arr n = int(input()) int(input()) n def shellSort(arr, n):
    G = []
    g = 1
    cnt = 0
    while g < n or g == 1:
        G.append(g)
        g = 3*g + 1
    G = G[::-1]
    print(len(G))
    for i in range(len(G)):
        cnt += insertionSort(arr, n, G[i])
    print(*G)
    print(cnt)
    for a in arr:
        print(a) def shellSort(arr, n):
    G = []
    g = 1
    cnt = 0
    while g < n or g == 1:
        G.append(g)
        g = 3*g + 1
    G = G[::-1]
    print(len(G))
    for i in range(len(G)):
        cnt += insertionSort(arr, n, G[i])
    print(*G)
    print(cnt)
    for a in arr:
        print(a) shellSort def insertionSort(arr, n, g):
    cnt = 0
    for i in range(g, n):
        key = arr[i]
        j = i - g
        while j >= 0 and arr[j] > key:
            arr[j + g] = arr[j]
            j -= g
            cnt += 1
        arr[j + g] = key
    return cnt def insertionSort(arr, n, g):
    cnt = 0
    for i in range(g, n):
        key = arr[i]
        j = i - g
        while j >= 0 and arr[j] > key:
            arr[j + g] = arr[j]
            j -= g
            cnt += 1
        arr[j + g] = key
    return cnt insertionSort
n = int(input())
arr = [int(input()) for _ in range(n)] 

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

def shellSort(arr, n):
    G = []
    g = 1
    cnt = 0
    while g < n or g == 1:
        G.append(g)
        g = 3*g + 1
    G = G[::-1]
    print(len(G))
    for i in range(len(G)):
        cnt += insertionSort(arr, n, G[i])
    print(*G)
    print(cnt)
    for a in arr:
        print(a)

shellSort(arr, n)
