
def insertationSort(sort_list, n, g):
    cnt = 0
    for i in range(g, n):
        v = sort_list[i]
        j = i - g

        while j >= 0 and sort_list[j] > v:
            sort_list[j + g] = sort_list[j]
            j -= g
            cnt += 1
        sort_list[j + g] = v

    return cnt


def shellSort(sort_list, n):

    cnt = 0

    G = [1]

    while True:
        if G[len(G)-1] * 3 + 1 <= n:
            G.append(G[len(G)-1] * 3 + 1)
        else:
            break

    m = len(G)


    for i in G[::-1]:
        cnt += insertationSort(sort_list, n, i)

    print(m)
    print(' '.join([str(i) for i in G[::-1]]))
    print(cnt)
    for ans in sort_list:
        print(ans)


if __name__ == "__main__":
    N = int(input())

    sort_list = list()

    for _ in range(N):
        sort_list.append(int(input()))

    shellSort(sort_list, N) def insertationSort(sort_list, n, g):
    cnt = 0
    for i in range(g, n):
        v = sort_list[i]
        j = i - g

        while j >= 0 and sort_list[j] > v:
            sort_list[j + g] = sort_list[j]
            j -= g
            cnt += 1
        sort_list[j + g] = v

    return cnt insertationSort cnt = 0 cnt 0 for i in range(g, n):
        v = sort_list[i]
        j = i - g

        while j >= 0 and sort_list[j] > v:
            sort_list[j + g] = sort_list[j]
            j -= g
            cnt += 1
        sort_list[j + g] = v

     i range(g, n) range g n v = sort_list[i] v sort_list[i] sort_list i j = i - g j i - g i g while j >= 0 and sort_list[j] > v:
            sort_list[j + g] = sort_list[j]
            j -= g
            cnt += 1
         j >= 0 and sort_list[j] > v j >= 0 j 0 sort_list[j] > v sort_list[j] sort_list j v sort_list[j + g] = sort_list[j] sort_list[j + g] sort_list j + g j g sort_list[j] sort_list j j -= g j g cnt += 1 cnt 1 sort_list[j + g] = v sort_list[j + g] sort_list j + g j g v return cnt cnt sort_list sort_list n n g g def shellSort(sort_list, n):

    cnt = 0

    G = [1]

    while True:
        if G[len(G)-1] * 3 + 1 <= n:
            G.append(G[len(G)-1] * 3 + 1)
        else:
            break

    m = len(G)


    for i in G[::-1]:
        cnt += insertationSort(sort_list, n, i)

    print(m)
    print(' '.join([str(i) for i in G[::-1]]))
    print(cnt)
    for ans in sort_list:
        print(ans) shellSort cnt = 0 cnt 0 G = [1] G [1] 1 while True:
        if G[len(G)-1] * 3 + 1 <= n:
            G.append(G[len(G)-1] * 3 + 1)
        else:
            break

     True if G[len(G)-1] * 3 + 1 <= n:
            G.append(G[len(G)-1] * 3 + 1)
        else:
            break

     G[len(G)-1] * 3 + 1 <= n G[len(G)-1] * 3 + 1 G[len(G)-1] * 3 G[len(G)-1] G len(G)-1 len(G) len G 1 3 1 n G.append(G[len(G)-1] * 3 + 1) G.append G append G[len(G)-1] * 3 + 1 G[len(G)-1] * 3 G[len(G)-1] G len(G)-1 len(G) len G 1 3 1 break m = len(G) m len(G) len G for i in G[::-1]:
        cnt += insertationSort(sort_list, n, i)

     i G[::-1] G ::-1 -1 cnt += insertationSort(sort_list, n, i) cnt insertationSort(sort_list, n, i) insertationSort sort_list n i print(m) print m str(i) for i in G[::-1] for i in G[::-1] i G[::-1] G ::-1 -1 for i in G[::-1] str(i) str i print(' '.join([str(i) for i in G[::-1]])) print ' '.join([str(i) for i in G[::-1]]) ' '.join ' ' join [str(i) for i in G[::-1]] print(cnt) print cnt for ans in sort_list:
        print(ans) ans sort_list print(ans) print ans sort_list sort_list n n if __name__ == "__main__":
    N = int(input())

    sort_list = list()

    for _ in range(N):
        sort_list.append(int(input()))

    shellSort(sort_list, N) __name__ == "__main__" __name__ "__main__" N = int(input()) N int(input()) int input() input sort_list = list() sort_list list() list for _ in range(N):
        sort_list.append(int(input()))

     _ range(N) range N sort_list.append(int(input())) sort_list.append sort_list append int(input()) int input() input shellSort(sort_list, N) shellSort sort_list N sort_list = list() list() sort_list N = int(input()) int(input()) N def insertationSort(sort_list, n, g):
    cnt = 0
    for i in range(g, n):
        v = sort_list[i]
        j = i - g

        while j >= 0 and sort_list[j] > v:
            sort_list[j + g] = sort_list[j]
            j -= g
            cnt += 1
        sort_list[j + g] = v

    return cnt def insertationSort(sort_list, n, g):
    cnt = 0
    for i in range(g, n):
        v = sort_list[i]
        j = i - g

        while j >= 0 and sort_list[j] > v:
            sort_list[j + g] = sort_list[j]
            j -= g
            cnt += 1
        sort_list[j + g] = v

    return cnt insertationSort def shellSort(sort_list, n):

    cnt = 0

    G = [1]

    while True:
        if G[len(G)-1] * 3 + 1 <= n:
            G.append(G[len(G)-1] * 3 + 1)
        else:
            break

    m = len(G)


    for i in G[::-1]:
        cnt += insertationSort(sort_list, n, i)

    print(m)
    print(' '.join([str(i) for i in G[::-1]]))
    print(cnt)
    for ans in sort_list:
        print(ans) def shellSort(sort_list, n):

    cnt = 0

    G = [1]

    while True:
        if G[len(G)-1] * 3 + 1 <= n:
            G.append(G[len(G)-1] * 3 + 1)
        else:
            break

    m = len(G)


    for i in G[::-1]:
        cnt += insertationSort(sort_list, n, i)

    print(m)
    print(' '.join([str(i) for i in G[::-1]]))
    print(cnt)
    for ans in sort_list:
        print(ans) shellSort

def insertationSort(sort_list, n, g):
    cnt = 0
    for i in range(g, n):
        v = sort_list[i]
        j = i - g

        while j >= 0 and sort_list[j] > v:
            sort_list[j + g] = sort_list[j]
            j -= g
            cnt += 1
        sort_list[j + g] = v

    return cnt


def shellSort(sort_list, n):

    cnt = 0

    G = [1]

    while True:
        if G[len(G)-1] * 3 + 1 <= n:
            G.append(G[len(G)-1] * 3 + 1)
        else:
            break

    m = len(G)


    for i in G[::-1]:
        cnt += insertationSort(sort_list, n, i)

    print(m)
    print(' '.join([str(i) for i in G[::-1]]))
    print(cnt)
    for ans in sort_list:
        print(ans)


if __name__ == "__main__":
    N = int(input())

    sort_list = list()

    for _ in range(N):
        sort_list.append(int(input()))

    shellSort(sort_list, N)
