N = int(input())
ary = [int(input()) for _ in range(N)]


def insertion_sort(ary, g):
    cnt = 0

    for i in range(g, N):
        v = ary[i]
        j = i - g

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

        ary[j + g] = v

    return cnt


def shell_sort(ary):

    g = [1]
    while True:
        if 3 * g[-1] + 1 < N:
            g.append(3 * g[-1] + 1)
        else:
            break

    m = len(g)
    g = g[::-1]
    cnt = 0
    for i in range(0, m):
        cnt += insertion_sort(ary, g[i])

    print(m)
    print(' '.join([str(_) for _ in g]))
    print(cnt)
    [print(_) for _ in ary]


shell_sort(ary)
 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 ary = [int(input()) for _ in range(N)] ary [int(input()) for _ in range(N)] def insertion_sort(ary, g):
    cnt = 0

    for i in range(g, N):
        v = ary[i]
        j = i - g

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

        ary[j + g] = v

    return cnt insertion_sort cnt = 0 cnt 0 for i in range(g, N):
        v = ary[i]
        j = i - g

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

        ary[j + g] = v

     i range(g, N) range g N v = ary[i] v ary[i] ary i j = i - g j i - g i g while j >= 0 and ary[j] > v:
            ary[j + g] = ary[j]
            j -= g
            cnt += 1

         j >= 0 and ary[j] > v j >= 0 j 0 ary[j] > v ary[j] ary j v ary[j + g] = ary[j] ary[j + g] ary j + g j g ary[j] ary j j -= g j g cnt += 1 cnt 1 ary[j + g] = v ary[j + g] ary j + g j g v return cnt cnt ary ary g g def shell_sort(ary):

    g = [1]
    while True:
        if 3 * g[-1] + 1 < N:
            g.append(3 * g[-1] + 1)
        else:
            break

    m = len(g)
    g = g[::-1]
    cnt = 0
    for i in range(0, m):
        cnt += insertion_sort(ary, g[i])

    print(m)
    print(' '.join([str(_) for _ in g]))
    print(cnt)
    [print(_) for _ in ary] shell_sort g = [1] g [1] 1 while True:
        if 3 * g[-1] + 1 < N:
            g.append(3 * g[-1] + 1)
        else:
            break

     True if 3 * g[-1] + 1 < N:
            g.append(3 * g[-1] + 1)
        else:
            break

     3 * g[-1] + 1 < N 3 * g[-1] + 1 3 * g[-1] 3 g[-1] g -1 1 N g.append(3 * g[-1] + 1) g.append g append 3 * g[-1] + 1 3 * g[-1] 3 g[-1] g -1 1 break m = len(g) m len(g) len g g = g[::-1] g g[::-1] g ::-1 -1 cnt = 0 cnt 0 for i in range(0, m):
        cnt += insertion_sort(ary, g[i])

     i range(0, m) range 0 m cnt += insertion_sort(ary, g[i]) cnt insertion_sort(ary, g[i]) insertion_sort ary g[i] g i print(m) print m str(_) for _ in g for _ in g _ g for _ in g str(_) str _ print(' '.join([str(_) for _ in g])) print ' '.join([str(_) for _ in g]) ' '.join ' ' join [str(_) for _ in g] print(cnt) print cnt print(_) for _ in ary for _ in ary _ ary for _ in ary print(_) print _ [print(_) for _ in ary] ary ary shell_sort(ary) shell_sort ary ary = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] ary def insertion_sort(ary, g):
    cnt = 0

    for i in range(g, N):
        v = ary[i]
        j = i - g

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

        ary[j + g] = v

    return cnt def insertion_sort(ary, g):
    cnt = 0

    for i in range(g, N):
        v = ary[i]
        j = i - g

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

        ary[j + g] = v

    return cnt insertion_sort N = int(input()) int(input()) N def shell_sort(ary):

    g = [1]
    while True:
        if 3 * g[-1] + 1 < N:
            g.append(3 * g[-1] + 1)
        else:
            break

    m = len(g)
    g = g[::-1]
    cnt = 0
    for i in range(0, m):
        cnt += insertion_sort(ary, g[i])

    print(m)
    print(' '.join([str(_) for _ in g]))
    print(cnt)
    [print(_) for _ in ary] def shell_sort(ary):

    g = [1]
    while True:
        if 3 * g[-1] + 1 < N:
            g.append(3 * g[-1] + 1)
        else:
            break

    m = len(g)
    g = g[::-1]
    cnt = 0
    for i in range(0, m):
        cnt += insertion_sort(ary, g[i])

    print(m)
    print(' '.join([str(_) for _ in g]))
    print(cnt)
    [print(_) for _ in ary] shell_sort
N = int(input())
ary = [int(input()) for _ in range(N)]


def insertion_sort(ary, g):
    cnt = 0

    for i in range(g, N):
        v = ary[i]
        j = i - g

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

        ary[j + g] = v

    return cnt


def shell_sort(ary):

    g = [1]
    while True:
        if 3 * g[-1] + 1 < N:
            g.append(3 * g[-1] + 1)
        else:
            break

    m = len(g)
    g = g[::-1]
    cnt = 0
    for i in range(0, m):
        cnt += insertion_sort(ary, g[i])

    print(m)
    print(' '.join([str(_) for _ in g]))
    print(cnt)
    [print(_) for _ in ary]


shell_sort(ary)

