import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque
import copy

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def insertion_sort(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 shell_sort(A, N, G, m):
    cnt = 0
    for i in range(m):
        cnt += insertion_sort(A, N, G[i])
    return cnt


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = [ii() for _ in range(N)]

    G = [1]
    for i in range(N):
        g = G[i] * 3 + 1
        if g > N:
            break
        else:
            G.append(g)
    m = len(G)
    G = G[::-1]
    cnt = shell_sort(A, N, G, m)

    print(m)
    print(*G)
    print(cnt)
    print(*A, sep='\n')


if __name__ == '__main__':
    main()
 import sys, os, math, bisect, itertools, collections, heapq, queue sys os math bisect itertools collections heapq queue from decimal import Decimal from collections import defaultdict, deque import copy copy sys.setrecursionlimit(10000000) sys.setrecursionlimit sys setrecursionlimit 10000000 ii = lambda: int(sys.stdin.buffer.readline().rstrip()) ii lambda: int(sys.stdin.buffer.readline().rstrip()) int(sys.stdin.buffer.readline().rstrip()) int sys.stdin.buffer.readline().rstrip() sys.stdin.buffer.readline().rstrip sys.stdin.buffer.readline() sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline rstrip il = lambda: list(map(int, sys.stdin.buffer.readline().split())) il lambda: list(map(int, sys.stdin.buffer.readline().split())) list(map(int, sys.stdin.buffer.readline().split())) list map(int, sys.stdin.buffer.readline().split()) map int sys.stdin.buffer.readline().split() sys.stdin.buffer.readline().split sys.stdin.buffer.readline() sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline split fl = lambda: list(map(float, sys.stdin.buffer.readline().split())) fl lambda: list(map(float, sys.stdin.buffer.readline().split())) list(map(float, sys.stdin.buffer.readline().split())) list map(float, sys.stdin.buffer.readline().split()) map float sys.stdin.buffer.readline().split() sys.stdin.buffer.readline().split sys.stdin.buffer.readline() sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline split int(sys.stdin.buffer.readline().rstrip()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(sys.stdin.buffer.readline().rstrip()) int sys.stdin.buffer.readline().rstrip() sys.stdin.buffer.readline().rstrip sys.stdin.buffer.readline() sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline rstrip iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)] iln lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)] [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)] n iss = lambda: sys.stdin.buffer.readline().decode().rstrip() iss lambda: sys.stdin.buffer.readline().decode().rstrip() sys.stdin.buffer.readline().decode().rstrip() sys.stdin.buffer.readline().decode().rstrip sys.stdin.buffer.readline().decode() sys.stdin.buffer.readline().decode sys.stdin.buffer.readline() sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline decode rstrip sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split())) sl lambda: list(map(str, sys.stdin.buffer.readline().decode().split())) list(map(str, sys.stdin.buffer.readline().decode().split())) list map(str, sys.stdin.buffer.readline().decode().split()) map str sys.stdin.buffer.readline().decode().split() sys.stdin.buffer.readline().decode().split sys.stdin.buffer.readline().decode() sys.stdin.buffer.readline().decode sys.stdin.buffer.readline() sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline decode split sys.stdin.buffer.readline().decode().rstrip() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) sys.stdin.buffer.readline().decode().rstrip() sys.stdin.buffer.readline().decode().rstrip sys.stdin.buffer.readline().decode() sys.stdin.buffer.readline().decode sys.stdin.buffer.readline() sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline decode rstrip isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)] isn lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)] [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)] n lcm = lambda x, y: (x * y) // math.gcd(x, y) lcm lambda x, y: (x * y) // math.gcd(x, y) (x * y) // math.gcd(x, y) x * y x y math.gcd(x, y) math.gcd math gcd x y x y MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 MAX = float('inf') MAX float('inf') float 'inf' def insertion_sort(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 insertion_sort 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 shell_sort(A, N, G, m):
    cnt = 0
    for i in range(m):
        cnt += insertion_sort(A, N, G[i])
    return cnt shell_sort cnt = 0 cnt 0 for i in range(m):
        cnt += insertion_sort(A, N, G[i])
     i range(m) range m cnt += insertion_sort(A, N, G[i]) cnt insertion_sort(A, N, G[i]) insertion_sort A N G[i] G i return cnt cnt A A N N G G m m def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = [ii() for _ in range(N)]

    G = [1]
    for i in range(N):
        g = G[i] * 3 + 1
        if g > N:
            break
        else:
            G.append(g)
    m = len(G)
    G = G[::-1]
    cnt = shell_sort(A, N, G, m)

    print(m)
    print(*G)
    print(cnt)
    print(*A, sep='\n') main if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

     os.getenv("LOCAL") os.getenv os getenv "LOCAL" sys.stdin = open("input.txt", "r") sys.stdin sys stdin open("input.txt", "r") open "input.txt" "r" N = ii() N ii() ii ii() for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) ii() ii A = [ii() for _ in range(N)] A [ii() for _ in range(N)] G = [1] G [1] 1 for i in range(N):
        g = G[i] * 3 + 1
        if g > N:
            break
        else:
            G.append(g)
     i range(N) range N g = G[i] * 3 + 1 g G[i] * 3 + 1 G[i] * 3 G[i] G i 3 1 if g > N:
            break
        else:
            G.append(g)
     g > N g N break G.append(g) G.append G append g m = len(G) m len(G) len G G = G[::-1] G G[::-1] G ::-1 -1 cnt = shell_sort(A, N, G, m) cnt shell_sort(A, N, G, m) shell_sort A N G m print(m) print m print(*G) print *G G print(cnt) print cnt print(*A, sep='\n') print *A A sep='\n' sep '\n' if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main fl = lambda: list(map(float, sys.stdin.buffer.readline().split())) lambda: list(map(float, sys.stdin.buffer.readline().split())) fl sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split())) lambda: list(map(str, sys.stdin.buffer.readline().decode().split())) sl lcm = lambda x, y: (x * y) // math.gcd(x, y) lambda x, y: (x * y) // math.gcd(x, y) lcm il = lambda: list(map(int, sys.stdin.buffer.readline().split())) lambda: list(map(int, sys.stdin.buffer.readline().split())) il ii = lambda: int(sys.stdin.buffer.readline().rstrip()) lambda: int(sys.stdin.buffer.readline().rstrip()) ii def insertion_sort(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 insertion_sort(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 insertion_sort MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)] lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)] iln iss = lambda: sys.stdin.buffer.readline().decode().rstrip() lambda: sys.stdin.buffer.readline().decode().rstrip() iss isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)] lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)] isn def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = [ii() for _ in range(N)]

    G = [1]
    for i in range(N):
        g = G[i] * 3 + 1
        if g > N:
            break
        else:
            G.append(g)
    m = len(G)
    G = G[::-1]
    cnt = shell_sort(A, N, G, m)

    print(m)
    print(*G)
    print(cnt)
    print(*A, sep='\n') def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = [ii() for _ in range(N)]

    G = [1]
    for i in range(N):
        g = G[i] * 3 + 1
        if g > N:
            break
        else:
            G.append(g)
    m = len(G)
    G = G[::-1]
    cnt = shell_sort(A, N, G, m)

    print(m)
    print(*G)
    print(cnt)
    print(*A, sep='\n') main MAX = float('inf') float('inf') MAX def shell_sort(A, N, G, m):
    cnt = 0
    for i in range(m):
        cnt += insertion_sort(A, N, G[i])
    return cnt def shell_sort(A, N, G, m):
    cnt = 0
    for i in range(m):
        cnt += insertion_sort(A, N, G[i])
    return cnt shell_sort
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque
import copy

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def insertion_sort(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 shell_sort(A, N, G, m):
    cnt = 0
    for i in range(m):
        cnt += insertion_sort(A, N, G[i])
    return cnt


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = [ii() for _ in range(N)]

    G = [1]
    for i in range(N):
        g = G[i] * 3 + 1
        if g > N:
            break
        else:
            G.append(g)
    m = len(G)
    G = G[::-1]
    cnt = shell_sort(A, N, G, m)

    print(m)
    print(*G)
    print(cnt)
    print(*A, sep='\n')


if __name__ == '__main__':
    main()

