n = int(input())
L = []
for _ in range(n):
    L.append(int(input()))

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


def ShellSort(L, n):
    gt = 1
    g = []
    while n >= gt:
        g.append(gt)
        gt = 3 * gt + 1
    print(len(g))
    g = g[::-1]
    print(' '.join(str(x) for x in g))
    for x in g:
        InsertionSort(L, n, x)
    print(cnt)
    for i in L:
        print(i)

cnt = 0
ShellSort(L, n) n = int(input()) n int(input()) int input() input L = [] L [] for _ in range(n):
    L.append(int(input())) _ range(n) range n L.append(int(input())) L.append L append int(input()) int input() input def InsertionSort(L, n, g):  
    for i in range(n):
        global cnt
        v = L[i]
        j = i - g
        while j >= 0 and L[j] > v:
            L[j+g] = L[j]
            j -= g
            cnt += 1
        L[j+g] = v InsertionSort for i in range(n):
        global cnt
        v = L[i]
        j = i - g
        while j >= 0 and L[j] > v:
            L[j+g] = L[j]
            j -= g
            cnt += 1
        L[j+g] = v i range(n) range n global cnt v = L[i] v L[i] L i j = i - g j i - g i g while j >= 0 and L[j] > v:
            L[j+g] = L[j]
            j -= g
            cnt += 1
         j >= 0 and L[j] > v j >= 0 j 0 L[j] > v L[j] L j v L[j+g] = L[j] L[j+g] L j+g j g L[j] L j j -= g j g cnt += 1 cnt 1 L[j+g] = v L[j+g] L j+g j g v L L n n g g def ShellSort(L, n):
    gt = 1
    g = []
    while n >= gt:
        g.append(gt)
        gt = 3 * gt + 1
    print(len(g))
    g = g[::-1]
    print(' '.join(str(x) for x in g))
    for x in g:
        InsertionSort(L, n, x)
    print(cnt)
    for i in L:
        print(i) ShellSort gt = 1 gt 1 g = [] g [] while n >= gt:
        g.append(gt)
        gt = 3 * gt + 1
     n >= gt n gt g.append(gt) g.append g append gt gt = 3 * gt + 1 gt 3 * gt + 1 3 * gt 3 gt 1 print(len(g)) print len(g) len g g = g[::-1] g g[::-1] g ::-1 -1 print(' '.join(str(x) for x in g)) print ' '.join(str(x) for x in g) ' '.join ' ' join str(x) str x for x in g:
        InsertionSort(L, n, x)
     x g InsertionSort(L, n, x) InsertionSort L n x print(cnt) print cnt for i in L:
        print(i) i L print(i) print i L L n n cnt = 0 cnt 0 ShellSort(L, n) ShellSort L n def InsertionSort(L, n, g):  
    for i in range(n):
        global cnt
        v = L[i]
        j = i - g
        while j >= 0 and L[j] > v:
            L[j+g] = L[j]
            j -= g
            cnt += 1
        L[j+g] = v def InsertionSort(L, n, g):  
    for i in range(n):
        global cnt
        v = L[i]
        j = i - g
        while j >= 0 and L[j] > v:
            L[j+g] = L[j]
            j -= g
            cnt += 1
        L[j+g] = v InsertionSort def ShellSort(L, n):
    gt = 1
    g = []
    while n >= gt:
        g.append(gt)
        gt = 3 * gt + 1
    print(len(g))
    g = g[::-1]
    print(' '.join(str(x) for x in g))
    for x in g:
        InsertionSort(L, n, x)
    print(cnt)
    for i in L:
        print(i) def ShellSort(L, n):
    gt = 1
    g = []
    while n >= gt:
        g.append(gt)
        gt = 3 * gt + 1
    print(len(g))
    g = g[::-1]
    print(' '.join(str(x) for x in g))
    for x in g:
        InsertionSort(L, n, x)
    print(cnt)
    for i in L:
        print(i) ShellSort L = [] [] L n = int(input()) int(input()) n cnt = 0 0 cnt
n = int(input())
L = []
for _ in range(n):
    L.append(int(input()))

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


def ShellSort(L, n):
    gt = 1
    g = []
    while n >= gt:
        g.append(gt)
        gt = 3 * gt + 1
    print(len(g))
    g = g[::-1]
    print(' '.join(str(x) for x in g))
    for x in g:
        InsertionSort(L, n, x)
    print(cnt)
    for i in L:
        print(i)

cnt = 0
ShellSort(L, n)
