def insertion_sort(l, g):
    cnt = 0
    for i in range(g, len(l)):
        tmp = l[i]
        j = i - g
        while j >= 0 and l[j] > tmp:
            l[j+g] = l[j]
            cnt += 1
            j -= g
        l[j+g] = tmp

    return l, cnt


def shell_sort(l, lg):
    tot = 0
    for g in lg:
        sl, cnt = insertion_sort(l, g)
        tot += cnt
    return sl, tot


if __name__ == '__main__':
    N = int(input())
    l = []
    for _ in range(N):
        l.append(int(input()))

    lg = [1]
    while True:
        gc = 3 * lg[-1] + 1
        if gc > N:
            break
        lg.append(gc)

    lg = lg[::-1]

    print(len(lg))
    print(' '.join(map(str, lg)))
    sl, tot = shell_sort(l, lg)
    print(tot)
    for e in sl:
        print(e)
 def insertion_sort(l, g):
    cnt = 0
    for i in range(g, len(l)):
        tmp = l[i]
        j = i - g
        while j >= 0 and l[j] > tmp:
            l[j+g] = l[j]
            cnt += 1
            j -= g
        l[j+g] = tmp

    return l, cnt insertion_sort cnt = 0 cnt 0 for i in range(g, len(l)):
        tmp = l[i]
        j = i - g
        while j >= 0 and l[j] > tmp:
            l[j+g] = l[j]
            cnt += 1
            j -= g
        l[j+g] = tmp

     i range(g, len(l)) range g len(l) len l tmp = l[i] tmp l[i] l i j = i - g j i - g i g while j >= 0 and l[j] > tmp:
            l[j+g] = l[j]
            cnt += 1
            j -= g
         j >= 0 and l[j] > tmp j >= 0 j 0 l[j] > tmp l[j] l j tmp l[j+g] = l[j] l[j+g] l j+g j g l[j] l j cnt += 1 cnt 1 j -= g j g l[j+g] = tmp l[j+g] l j+g j g tmp return l, cnt return l, cnt l cnt l l g g def shell_sort(l, lg):
    tot = 0
    for g in lg:
        sl, cnt = insertion_sort(l, g)
        tot += cnt
    return sl, tot shell_sort tot = 0 tot 0 for g in lg:
        sl, cnt = insertion_sort(l, g)
        tot += cnt
     g lg sl, cnt = insertion_sort(l, g) sl insertion_sort(l, g) insertion_sort l g cnt tot += cnt tot cnt return sl, tot return sl, tot sl tot l l lg lg if __name__ == '__main__':
    N = int(input())
    l = []
    for _ in range(N):
        l.append(int(input()))

    lg = [1]
    while True:
        gc = 3 * lg[-1] + 1
        if gc > N:
            break
        lg.append(gc)

    lg = lg[::-1]

    print(len(lg))
    print(' '.join(map(str, lg)))
    sl, tot = shell_sort(l, lg)
    print(tot)
    for e in sl:
        print(e) __name__ == '__main__' __name__ '__main__' N = int(input()) N int(input()) int input() input l = [] l [] for _ in range(N):
        l.append(int(input()))

     _ range(N) range N l.append(int(input())) l.append l append int(input()) int input() input lg = [1] lg [1] 1 while True:
        gc = 3 * lg[-1] + 1
        if gc > N:
            break
        lg.append(gc)

     True gc = 3 * lg[-1] + 1 gc 3 * lg[-1] + 1 3 * lg[-1] 3 lg[-1] lg -1 1 if gc > N:
            break
         gc > N gc N break lg.append(gc) lg.append lg append gc lg = lg[::-1] lg lg[::-1] lg ::-1 -1 print(len(lg)) print len(lg) len lg print(' '.join(map(str, lg))) print ' '.join(map(str, lg)) ' '.join ' ' join map(str, lg) map str lg sl, tot = shell_sort(l, lg) sl shell_sort(l, lg) shell_sort l lg tot print(tot) print tot for e in sl:
        print(e) e sl print(e) print e lg = lg[::-1] lg[::-1] lg gc = 3 * lg[-1] + 1 3 * lg[-1] + 1 gc l = [] [] l tot = shell_sort(l, lg) shell_sort(l, lg) tot lg = [1] [1] lg sl, tot = shell_sort(l, lg) shell_sort(l, lg) sl def shell_sort(l, lg):
    tot = 0
    for g in lg:
        sl, cnt = insertion_sort(l, g)
        tot += cnt
    return sl, tot def shell_sort(l, lg):
    tot = 0
    for g in lg:
        sl, cnt = insertion_sort(l, g)
        tot += cnt
    return sl, tot shell_sort def insertion_sort(l, g):
    cnt = 0
    for i in range(g, len(l)):
        tmp = l[i]
        j = i - g
        while j >= 0 and l[j] > tmp:
            l[j+g] = l[j]
            cnt += 1
            j -= g
        l[j+g] = tmp

    return l, cnt def insertion_sort(l, g):
    cnt = 0
    for i in range(g, len(l)):
        tmp = l[i]
        j = i - g
        while j >= 0 and l[j] > tmp:
            l[j+g] = l[j]
            cnt += 1
            j -= g
        l[j+g] = tmp

    return l, cnt insertion_sort N = int(input()) int(input()) N
def insertion_sort(l, g):
    cnt = 0
    for i in range(g, len(l)):
        tmp = l[i]
        j = i - g
        while j >= 0 and l[j] > tmp:
            l[j+g] = l[j]
            cnt += 1
            j -= g
        l[j+g] = tmp

    return l, cnt


def shell_sort(l, lg):
    tot = 0
    for g in lg:
        sl, cnt = insertion_sort(l, g)
        tot += cnt
    return sl, tot


if __name__ == '__main__':
    N = int(input())
    l = []
    for _ in range(N):
        l.append(int(input()))

    lg = [1]
    while True:
        gc = 3 * lg[-1] + 1
        if gc > N:
            break
        lg.append(gc)

    lg = lg[::-1]

    print(len(lg))
    print(' '.join(map(str, lg)))
    sl, tot = shell_sort(l, lg)
    print(tot)
    for e in sl:
        print(e)

