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, A

def shellSort(A, n):
    cnt = 0
    g = [1]
    while g[-1] * 3 + 1 < n:
        g.append(g[-1] * 3 + 1)
    g.reverse()
    print(len(g))
    print(' '.join([str(_g) for _g in g]))
    for i in range(len(g)):
        cnt, A = insertionSort(A, n, g[i], cnt)
    return cnt, A

def run():
    n = int(input())
    A = []
    for _ in range(n):
        A.append(int(input()))
    cnt, ans = shellSort(A, n)
    print(cnt)
    print('\n'.join([str(a) for a in ans]))

if __name__ == '__main__':
    run()

 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, A 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, A return cnt, A cnt A A A n n g g cnt cnt def shellSort(A, n):
    cnt = 0
    g = [1]
    while g[-1] * 3 + 1 < n:
        g.append(g[-1] * 3 + 1)
    g.reverse()
    print(len(g))
    print(' '.join([str(_g) for _g in g]))
    for i in range(len(g)):
        cnt, A = insertionSort(A, n, g[i], cnt)
    return cnt, A shellSort cnt = 0 cnt 0 g = [1] g [1] 1 while g[-1] * 3 + 1 < n:
        g.append(g[-1] * 3 + 1)
     g[-1] * 3 + 1 < n g[-1] * 3 + 1 g[-1] * 3 g[-1] g -1 3 1 n g.append(g[-1] * 3 + 1) g.append g append g[-1] * 3 + 1 g[-1] * 3 g[-1] g -1 3 1 g.reverse() g.reverse g reverse print(len(g)) print len(g) len g str(_g) for _g in g for _g in g _g g for _g in g str(_g) str _g print(' '.join([str(_g) for _g in g])) print ' '.join([str(_g) for _g in g]) ' '.join ' ' join [str(_g) for _g in g] for i in range(len(g)):
        cnt, A = insertionSort(A, n, g[i], cnt)
     i range(len(g)) range len(g) len g cnt, A = insertionSort(A, n, g[i], cnt) cnt insertionSort(A, n, g[i], cnt) insertionSort A n g[i] g i cnt A return cnt, A return cnt, A cnt A A A n n def run():
    n = int(input())
    A = []
    for _ in range(n):
        A.append(int(input()))
    cnt, ans = shellSort(A, n)
    print(cnt)
    print('\n'.join([str(a) for a in ans])) run n = int(input()) n int(input()) int input() input A = [] A [] for _ in range(n):
        A.append(int(input()))
     _ range(n) range n A.append(int(input())) A.append A append int(input()) int input() input cnt, ans = shellSort(A, n) cnt shellSort(A, n) shellSort A n ans print(cnt) print cnt str(a) for a in ans for a in ans a ans for a in ans str(a) str a print('\n'.join([str(a) for a in ans])) print '\n'.join([str(a) for a in ans]) '\n'.join '\n' join [str(a) for a in ans] if __name__ == '__main__':
    run() __name__ == '__main__' __name__ '__main__' run() run def run():
    n = int(input())
    A = []
    for _ in range(n):
        A.append(int(input()))
    cnt, ans = shellSort(A, n)
    print(cnt)
    print('\n'.join([str(a) for a in ans])) def run():
    n = int(input())
    A = []
    for _ in range(n):
        A.append(int(input()))
    cnt, ans = shellSort(A, n)
    print(cnt)
    print('\n'.join([str(a) for a in ans])) run def shellSort(A, n):
    cnt = 0
    g = [1]
    while g[-1] * 3 + 1 < n:
        g.append(g[-1] * 3 + 1)
    g.reverse()
    print(len(g))
    print(' '.join([str(_g) for _g in g]))
    for i in range(len(g)):
        cnt, A = insertionSort(A, n, g[i], cnt)
    return cnt, A def shellSort(A, n):
    cnt = 0
    g = [1]
    while g[-1] * 3 + 1 < n:
        g.append(g[-1] * 3 + 1)
    g.reverse()
    print(len(g))
    print(' '.join([str(_g) for _g in g]))
    for i in range(len(g)):
        cnt, A = insertionSort(A, n, g[i], cnt)
    return cnt, A 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, A 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, A insertionSort
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, A

def shellSort(A, n):
    cnt = 0
    g = [1]
    while g[-1] * 3 + 1 < n:
        g.append(g[-1] * 3 + 1)
    g.reverse()
    print(len(g))
    print(' '.join([str(_g) for _g in g]))
    for i in range(len(g)):
        cnt, A = insertionSort(A, n, g[i], cnt)
    return cnt, A

def run():
    n = int(input())
    A = []
    for _ in range(n):
        A.append(int(input()))
    cnt, ans = shellSort(A, n)
    print(cnt)
    print('\n'.join([str(a) for a in ans]))

if __name__ == '__main__':
    run()


