import math

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 -= g
            cnt += 1
        A[j + g] = v
    return cnt


def shellSort(A, n):
    cnt = 0
    j = int(math.log(2 * n + 1, 3)) + 1
    G = list(reversed([(3 ** i - 1)// 2 for i in range(1, j)]))
    m = len(G)
    for i in range(m):
        cnt += insertionSort(A, n, G[i])
    return A, cnt, G, m

n = int(input())
A = [int(input()) for i in range(n)]
ans, count, G, m = shellSort(A, n)
print(m)
print(' '.join(map(str,G)))
print(count)
[print(i) for i in A] import math math 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 -= 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 -= 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 -= 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 -= 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
    j = int(math.log(2 * n + 1, 3)) + 1
    G = list(reversed([(3 ** i - 1)// 2 for i in range(1, j)]))
    m = len(G)
    for i in range(m):
        cnt += insertionSort(A, n, G[i])
    return A, cnt, G, m shellSort cnt = 0 cnt 0 j = int(math.log(2 * n + 1, 3)) + 1 j int(math.log(2 * n + 1, 3)) + 1 int(math.log(2 * n + 1, 3)) int math.log(2 * n + 1, 3) math.log math log 2 * n + 1 2 * n 2 n 1 3 1 (3 ** i - 1)// 2 for i in range(1, j) for i in range(1, j) i range(1, j) range 1 j for i in range(1, j) (3 ** i - 1)// 2 3 ** i - 1 3 ** i 3 i 1 2 G = list(reversed([(3 ** i - 1)// 2 for i in range(1, j)])) G list(reversed([(3 ** i - 1)// 2 for i in range(1, j)])) list reversed([(3 ** i - 1)// 2 for i in range(1, j)]) reversed [(3 ** i - 1)// 2 for i in range(1, j)] m = len(G) m len(G) len 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 return A, cnt, G, m return A, cnt, G, m A cnt G m A A n n n = int(input()) n int(input()) int input() input int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input A = [int(input()) for i in range(n)] A [int(input()) for i in range(n)] ans, count, G, m = shellSort(A, n) ans shellSort(A, n) shellSort A n count G m print(m) print m print(' '.join(map(str,G))) print ' '.join(map(str,G)) ' '.join ' ' join map(str,G) map str G print(count) print count print(i) for i in A for i in A i A for i in A print(i) print i [print(i) for i in A] n = int(input()) int(input()) n 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 -= 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 -= g
            cnt += 1
        A[j + g] = v
    return cnt insertionSort A = [int(input()) for i in range(n)] [int(input()) for i in range(n)] A count, G, m = shellSort(A, n) shellSort(A, n) count G, m = shellSort(A, n) shellSort(A, n) G m = shellSort(A, n) shellSort(A, n) m def shellSort(A, n):
    cnt = 0
    j = int(math.log(2 * n + 1, 3)) + 1
    G = list(reversed([(3 ** i - 1)// 2 for i in range(1, j)]))
    m = len(G)
    for i in range(m):
        cnt += insertionSort(A, n, G[i])
    return A, cnt, G, m def shellSort(A, n):
    cnt = 0
    j = int(math.log(2 * n + 1, 3)) + 1
    G = list(reversed([(3 ** i - 1)// 2 for i in range(1, j)]))
    m = len(G)
    for i in range(m):
        cnt += insertionSort(A, n, G[i])
    return A, cnt, G, m shellSort ans, count, G, m = shellSort(A, n) shellSort(A, n) ans
import math

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 -= g
            cnt += 1
        A[j + g] = v
    return cnt


def shellSort(A, n):
    cnt = 0
    j = int(math.log(2 * n + 1, 3)) + 1
    G = list(reversed([(3 ** i - 1)// 2 for i in range(1, j)]))
    m = len(G)
    for i in range(m):
        cnt += insertionSort(A, n, G[i])
    return A, cnt, G, m

n = int(input())
A = [int(input()) for i in range(n)]
ans, count, G, m = shellSort(A, n)
print(m)
print(' '.join(map(str,G)))
print(count)
[print(i) for i in A]