cnt = 0
def show_list(a):
    for x in a:
        print x

def g_decide(n):
    g = []
    i = 1
    while True:
        tmp = (3**i-1)/2
        if tmp>=n:
            if len(g)==0:
                g.append(1)
            break
        g.append(tmp)
        i+=1
    return g

def insertion_sort(a,n,g):
    global cnt
    for i in xrange(g,n):
        v = a[i]
        j = i-g
        while j >=0 and a[j]>v:
            a[j+g] = a[j]
            j = j-g
            cnt+=1
        a[j+g] = v

def shell_sort(a,n):
    g = sorted(g_decide(n),reverse=True)
    m = len(g)
    print m
    print " ".join(map(str,g))
    for i in xrange(m):
        insertion_sort(a,n,g[i])
    print cnt
    show_list(a)

def main():
    n = input()
    a = []
    for i in xrange(n):
        a.append(input())
    shell_sort(a,n)

if __name__ == '__main__':
    main() cnt = 0 cnt 0 def show_list(a):
    for x in a:
        print x show_list for x in a:
        print x x a print a a def g_decide(n):
    g = []
    i = 1
    while True:
        tmp = (3**i-1)/2
        if tmp>=n:
            if len(g)==0:
                g.append(1)
            break
        g.append(tmp)
        i+=1
    return g g_decide g = [] g [] i = 1 i 1 while True:
        tmp = (3**i-1)/2
        if tmp>=n:
            if len(g)==0:
                g.append(1)
            break
        g.append(tmp)
        i+=1
     True tmp = (3**i-1)/2 tmp (3**i-1)/2 3**i-1 3**i 3 i 1 2 if tmp>=n:
            if len(g)==0:
                g.append(1)
            break
         tmp>=n tmp n if len(g)==0:
                g.append(1)
             len(g)==0 len(g) len g 0 g.append(1) g.append g append 1 break g.append(tmp) g.append g append tmp i+=1 i 1 return g g n n def insertion_sort(a,n,g):
    global cnt
    for i in xrange(g,n):
        v = a[i]
        j = i-g
        while j >=0 and a[j]>v:
            a[j+g] = a[j]
            j = j-g
            cnt+=1
        a[j+g] = v insertion_sort global cnt for i in xrange(g,n):
        v = a[i]
        j = i-g
        while j >=0 and a[j]>v:
            a[j+g] = a[j]
            j = j-g
            cnt+=1
        a[j+g] = v i xrange(g,n) xrange 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 = j-g
            cnt+=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 = j-g j j-g j g cnt+=1 cnt 1 a[j+g] = v a[j+g] a j+g j g v a a n n g g def shell_sort(a,n):
    g = sorted(g_decide(n),reverse=True)
    m = len(g)
    print m
    print " ".join(map(str,g))
    for i in xrange(m):
        insertion_sort(a,n,g[i])
    print cnt
    show_list(a) shell_sort g = sorted(g_decide(n),reverse=True) g sorted(g_decide(n),reverse=True) sorted g_decide(n) g_decide n reverse=True reverse True m = len(g) m len(g) len g print print " ".join(map(str,g)) " ".join " " join map(str,g) map str g for i in xrange(m):
        insertion_sort(a,n,g[i])
     i xrange(m) xrange m insertion_sort(a,n,g[i]) insertion_sort a n g[i] g i print show_list(a) show_list a a a n n def main():
    n = input()
    a = []
    for i in xrange(n):
        a.append(input())
    shell_sort(a,n) main n = input() n input() input a = [] a [] for i in xrange(n):
        a.append(input())
     i xrange(n) xrange n a.append(input()) a.append a append input() input shell_sort(a,n) shell_sort a n if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def show_list(a):
    for x in a:
        print x def show_list(a):
    for x in a:
        print x show_list def shell_sort(a,n):
    g = sorted(g_decide(n),reverse=True)
    m = len(g)
    print m
    print " ".join(map(str,g))
    for i in xrange(m):
        insertion_sort(a,n,g[i])
    print cnt
    show_list(a) def shell_sort(a,n):
    g = sorted(g_decide(n),reverse=True)
    m = len(g)
    print m
    print " ".join(map(str,g))
    for i in xrange(m):
        insertion_sort(a,n,g[i])
    print cnt
    show_list(a) shell_sort def main():
    n = input()
    a = []
    for i in xrange(n):
        a.append(input())
    shell_sort(a,n) def main():
    n = input()
    a = []
    for i in xrange(n):
        a.append(input())
    shell_sort(a,n) main cnt = 0 0 cnt def g_decide(n):
    g = []
    i = 1
    while True:
        tmp = (3**i-1)/2
        if tmp>=n:
            if len(g)==0:
                g.append(1)
            break
        g.append(tmp)
        i+=1
    return g def g_decide(n):
    g = []
    i = 1
    while True:
        tmp = (3**i-1)/2
        if tmp>=n:
            if len(g)==0:
                g.append(1)
            break
        g.append(tmp)
        i+=1
    return g g_decide def insertion_sort(a,n,g):
    global cnt
    for i in xrange(g,n):
        v = a[i]
        j = i-g
        while j >=0 and a[j]>v:
            a[j+g] = a[j]
            j = j-g
            cnt+=1
        a[j+g] = v def insertion_sort(a,n,g):
    global cnt
    for i in xrange(g,n):
        v = a[i]
        j = i-g
        while j >=0 and a[j]>v:
            a[j+g] = a[j]
            j = j-g
            cnt+=1
        a[j+g] = v insertion_sort
cnt = 0
def show_list(a):
    for x in a:
        print x

def g_decide(n):
    g = []
    i = 1
    while True:
        tmp = (3**i-1)/2
        if tmp>=n:
            if len(g)==0:
                g.append(1)
            break
        g.append(tmp)
        i+=1
    return g

def insertion_sort(a,n,g):
    global cnt
    for i in xrange(g,n):
        v = a[i]
        j = i-g
        while j >=0 and a[j]>v:
            a[j+g] = a[j]
            j = j-g
            cnt+=1
        a[j+g] = v

def shell_sort(a,n):
    g = sorted(g_decide(n),reverse=True)
    m = len(g)
    print m
    print " ".join(map(str,g))
    for i in xrange(m):
        insertion_sort(a,n,g[i])
    print cnt
    show_list(a)

def main():
    n = input()
    a = []
    for i in xrange(n):
        a.append(input())
    shell_sort(a,n)

if __name__ == '__main__':
    main()