def iSort(A, n, g):
    c = 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
            c += 1
        A[j+g] = v
    return c

def shellSort(A, n):
    cnt = 0
    G = list()
    h = 1
    while True:
        if h > n:
            break
        G.append(h)
        h = 3*h + 1
    G.reverse()
    for num in G:
        cnt += iSort(A, n, num)
    return cnt, A, G

if __name__ == '__main__':
    n = int(input())
    hoge = list()
    for _ in range(n):
        hoge.append(int(input()))
    cnt, hoge, G = shellSort(hoge, n)
    print (len(G))
    print (' '.join([str(x) for x in G]))
    print (cnt)
    for e in hoge:
        print (e) def iSort(A, n, g):
    c = 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
            c += 1
        A[j+g] = v
    return c iSort c = 0 c 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
            c += 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
            c += 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 c += 1 c 1 A[j+g] = v A[j+g] A j+g j g v return c c A A n n g g def shellSort(A, n):
    cnt = 0
    G = list()
    h = 1
    while True:
        if h > n:
            break
        G.append(h)
        h = 3*h + 1
    G.reverse()
    for num in G:
        cnt += iSort(A, n, num)
    return cnt, A, G shellSort cnt = 0 cnt 0 G = list() G list() list 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 G.reverse() G.reverse G reverse for num in G:
        cnt += iSort(A, n, num)
     num G cnt += iSort(A, n, num) cnt iSort(A, n, num) iSort A n num return cnt, A, G return cnt, A, G cnt A G A A n n if __name__ == '__main__':
    n = int(input())
    hoge = list()
    for _ in range(n):
        hoge.append(int(input()))
    cnt, hoge, G = shellSort(hoge, n)
    print (len(G))
    print (' '.join([str(x) for x in G]))
    print (cnt)
    for e in hoge:
        print (e) __name__ == '__main__' __name__ '__main__' n = int(input()) n int(input()) int input() input hoge = list() hoge list() list for _ in range(n):
        hoge.append(int(input()))
     _ range(n) range n hoge.append(int(input())) hoge.append hoge append int(input()) int input() input cnt, hoge, G = shellSort(hoge, n) cnt shellSort(hoge, n) shellSort hoge n hoge G print (len(G)) print len(G) len G str(x) for x in G for x in G x G for x in G str(x) str x print (' '.join([str(x) for x in G])) print ' '.join([str(x) for x in G]) ' '.join ' ' join [str(x) for x in G] print (cnt) print cnt for e in hoge:
        print (e) e hoge print (e) print e cnt, hoge, G = shellSort(hoge, n) shellSort(hoge, n) cnt def shellSort(A, n):
    cnt = 0
    G = list()
    h = 1
    while True:
        if h > n:
            break
        G.append(h)
        h = 3*h + 1
    G.reverse()
    for num in G:
        cnt += iSort(A, n, num)
    return cnt, A, G def shellSort(A, n):
    cnt = 0
    G = list()
    h = 1
    while True:
        if h > n:
            break
        G.append(h)
        h = 3*h + 1
    G.reverse()
    for num in G:
        cnt += iSort(A, n, num)
    return cnt, A, G shellSort hoge = list() list() hoge hoge, G = shellSort(hoge, n) shellSort(hoge, n) hoge G = shellSort(hoge, n) shellSort(hoge, n) G n = int(input()) int(input()) n def iSort(A, n, g):
    c = 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
            c += 1
        A[j+g] = v
    return c def iSort(A, n, g):
    c = 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
            c += 1
        A[j+g] = v
    return c iSort
def iSort(A, n, g):
    c = 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
            c += 1
        A[j+g] = v
    return c

def shellSort(A, n):
    cnt = 0
    G = list()
    h = 1
    while True:
        if h > n:
            break
        G.append(h)
        h = 3*h + 1
    G.reverse()
    for num in G:
        cnt += iSort(A, n, num)
    return cnt, A, G

if __name__ == '__main__':
    n = int(input())
    hoge = list()
    for _ in range(n):
        hoge.append(int(input()))
    cnt, hoge, G = shellSort(hoge, n)
    print (len(G))
    print (' '.join([str(x) for x in G]))
    print (cnt)
    for e in hoge:
        print (e)
