import math
import sys


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


def shellSort(data, N, G, cnt):
    
    h = 1
    while (True):
        if h > N:
            break
        G.append(h)
        h = 3 * h + 1
    
    m = len(G)
    G.reverse()
    

    for i in range(m):
        data, cnt = insertionSort(data, N, G[i], cnt)
        
    return m, G, cnt


def main():
    N = int(input())
    data = [int(input()) for _ in range(N)]
    
    cnt = 0
    G = []
    m = 0
    
    m, G, cnt = shellSort(data, N, G, cnt)
    
    print(m)
    print(' '.join(map(str, G)))
    print(cnt)
    for i in range(N):
        print(data[i])
    
if __name__ == '__main__':
    main() import math math import sys sys def insertionSort(data, N, g, cnt):
    
    for i in range(g, N):
        v = data[i]
        j = i - g
        while j >= 0 and data[j] > v:
            data[j+g] = data[j]
            j = j - g
            cnt += 1
        data[j+g] = v
        
    return data, cnt insertionSort for i in range(g, N):
        v = data[i]
        j = i - g
        while j >= 0 and data[j] > v:
            data[j+g] = data[j]
            j = j - g
            cnt += 1
        data[j+g] = v
        
     i range(g, N) range g N v = data[i] v data[i] data i j = i - g j i - g i g while j >= 0 and data[j] > v:
            data[j+g] = data[j]
            j = j - g
            cnt += 1
         j >= 0 and data[j] > v j >= 0 j 0 data[j] > v data[j] data j v data[j+g] = data[j] data[j+g] data j+g j g data[j] data j j = j - g j j - g j g cnt += 1 cnt 1 data[j+g] = v data[j+g] data j+g j g v return data, cnt return data, cnt data cnt data data N N g g cnt cnt def shellSort(data, N, G, cnt):
    
    h = 1
    while (True):
        if h > N:
            break
        G.append(h)
        h = 3 * h + 1
    
    m = len(G)
    G.reverse()
    

    for i in range(m):
        data, cnt = insertionSort(data, N, G[i], cnt)
        
    return m, G, cnt shellSort h = 1 h 1 while (True):
        if h > N:
            break
        G.append(h)
        h = 3 * h + 1
    
     True if h > N:
            break
         h > N h N break G.append(h) G.append G append h h = 3 * h + 1 h 3 * h + 1 3 * h 3 h 1 m = len(G) m len(G) len G G.reverse() G.reverse G reverse for i in range(m):
        data, cnt = insertionSort(data, N, G[i], cnt)
        
     i range(m) range m data, cnt = insertionSort(data, N, G[i], cnt) data insertionSort(data, N, G[i], cnt) insertionSort data N G[i] G i cnt cnt return m, G, cnt return m, G, cnt m G cnt data data N N G G cnt cnt def main():
    N = int(input())
    data = [int(input()) for _ in range(N)]
    
    cnt = 0
    G = []
    m = 0
    
    m, G, cnt = shellSort(data, N, G, cnt)
    
    print(m)
    print(' '.join(map(str, G)))
    print(cnt)
    for i in range(N):
        print(data[i])
     main 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 data = [int(input()) for _ in range(N)] data [int(input()) for _ in range(N)] cnt = 0 cnt 0 G = [] G [] m = 0 m 0 m, G, cnt = shellSort(data, N, G, cnt) m shellSort(data, N, G, cnt) shellSort data N G cnt G cnt print(m) print m print(' '.join(map(str, G))) print ' '.join(map(str, G)) ' '.join ' ' join map(str, G) map str G print(cnt) print cnt for i in range(N):
        print(data[i])
     i range(N) range N print(data[i]) print data[i] data i if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def insertionSort(data, N, g, cnt):
    
    for i in range(g, N):
        v = data[i]
        j = i - g
        while j >= 0 and data[j] > v:
            data[j+g] = data[j]
            j = j - g
            cnt += 1
        data[j+g] = v
        
    return data, cnt def insertionSort(data, N, g, cnt):
    
    for i in range(g, N):
        v = data[i]
        j = i - g
        while j >= 0 and data[j] > v:
            data[j+g] = data[j]
            j = j - g
            cnt += 1
        data[j+g] = v
        
    return data, cnt insertionSort def main():
    N = int(input())
    data = [int(input()) for _ in range(N)]
    
    cnt = 0
    G = []
    m = 0
    
    m, G, cnt = shellSort(data, N, G, cnt)
    
    print(m)
    print(' '.join(map(str, G)))
    print(cnt)
    for i in range(N):
        print(data[i])
     def main():
    N = int(input())
    data = [int(input()) for _ in range(N)]
    
    cnt = 0
    G = []
    m = 0
    
    m, G, cnt = shellSort(data, N, G, cnt)
    
    print(m)
    print(' '.join(map(str, G)))
    print(cnt)
    for i in range(N):
        print(data[i])
     main def shellSort(data, N, G, cnt):
    
    h = 1
    while (True):
        if h > N:
            break
        G.append(h)
        h = 3 * h + 1
    
    m = len(G)
    G.reverse()
    

    for i in range(m):
        data, cnt = insertionSort(data, N, G[i], cnt)
        
    return m, G, cnt def shellSort(data, N, G, cnt):
    
    h = 1
    while (True):
        if h > N:
            break
        G.append(h)
        h = 3 * h + 1
    
    m = len(G)
    G.reverse()
    

    for i in range(m):
        data, cnt = insertionSort(data, N, G[i], cnt)
        
    return m, G, cnt shellSort
import math
import sys


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


def shellSort(data, N, G, cnt):
    
    h = 1
    while (True):
        if h > N:
            break
        G.append(h)
        h = 3 * h + 1
    
    m = len(G)
    G.reverse()
    

    for i in range(m):
        data, cnt = insertionSort(data, N, G[i], cnt)
        
    return m, G, cnt


def main():
    N = int(input())
    data = [int(input()) for _ in range(N)]
    
    cnt = 0
    G = []
    m = 0
    
    m, G, cnt = shellSort(data, N, G, cnt)
    
    print(m)
    print(' '.join(map(str, G)))
    print(cnt)
    for i in range(N):
        print(data[i])
    
if __name__ == '__main__':
    main()
