def insertionSort(a,n,g):
    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 = j - g
            cnt[0] += 1
        a[j+g] = v
    return
    
def shellSort(a,n):
    h = 1
    while h <= n:
        g.append(h)
        h = 3*h + 1
    m[0] =  len(g)
    for i in range(m[0])[::-1]: insertionSort(a,n,g[i])
    return

if __name__ == "__main__":
    n = int(input())
    a = [int(input()) for _ in range(n)]
    g = []
    cnt = [0]
    m = [0]
    shellSort(a,n)
    print(m[0])
    print(" ".join(map(str,g[::-1])))
    print(cnt[0])
    print("\n".join(map(str,a))) def insertionSort(a,n,g):
    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 = j - g
            cnt[0] += 1
        a[j+g] = v
    return
     insertionSort 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 = j - g
            cnt[0] += 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 = j - g
            cnt[0] += 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[0] += 1 cnt[0] cnt 0 1 a[j+g] = v a[j+g] a j+g j g v return a a n n g g def shellSort(a,n):
    h = 1
    while h <= n:
        g.append(h)
        h = 3*h + 1
    m[0] =  len(g)
    for i in range(m[0])[::-1]: insertionSort(a,n,g[i])
    return shellSort h = 1 h 1 while h <= n:
        g.append(h)
        h = 3*h + 1
     h <= n h n g.append(h) g.append g append h h = 3*h + 1 h 3*h + 1 3*h 3 h 1 m[0] =  len(g) m[0] m 0 len(g) len g for i in range(m[0])[::-1]: insertionSort(a,n,g[i])
     i range(m[0])[::-1] (m[0]) range m[0] m 0 ::-1 -1 return a a n n if __name__ == "__main__":
    n = int(input())
    a = [int(input()) for _ in range(n)]
    g = []
    cnt = [0]
    m = [0]
    shellSort(a,n)
    print(m[0])
    print(" ".join(map(str,g[::-1])))
    print(cnt[0])
    print("\n".join(map(str,a))) __name__ == "__main__" __name__ "__main__" 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 a = [int(input()) for _ in range(n)] a [int(input()) for _ in range(n)] g = [] g [] cnt = [0] cnt [0] 0 m = [0] m [0] 0 shellSort(a,n) shellSort a n print(m[0]) print m[0] m 0 print(" ".join(map(str,g[::-1]))) print " ".join(map(str,g[::-1])) " ".join " " join map(str,g[::-1]) map str g[::-1] g ::-1 -1 print(cnt[0]) print cnt[0] cnt 0 print("\n".join(map(str,a))) print "\n".join(map(str,a)) "\n".join "\n" join map(str,a) map str a cnt = [0] [0] cnt def insertionSort(a,n,g):
    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 = j - g
            cnt[0] += 1
        a[j+g] = v
    return
     def insertionSort(a,n,g):
    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 = j - g
            cnt[0] += 1
        a[j+g] = v
    return
     insertionSort m = [0] [0] m n = int(input()) int(input()) n def shellSort(a,n):
    h = 1
    while h <= n:
        g.append(h)
        h = 3*h + 1
    m[0] =  len(g)
    for i in range(m[0])[::-1]: insertionSort(a,n,g[i])
    return def shellSort(a,n):
    h = 1
    while h <= n:
        g.append(h)
        h = 3*h + 1
    m[0] =  len(g)
    for i in range(m[0])[::-1]: insertionSort(a,n,g[i])
    return shellSort a = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] a g = [] [] g
def insertionSort(a,n,g):
    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 = j - g
            cnt[0] += 1
        a[j+g] = v
    return
    
def shellSort(a,n):
    h = 1
    while h <= n:
        g.append(h)
        h = 3*h + 1
    m[0] =  len(g)
    for i in range(m[0])[::-1]: insertionSort(a,n,g[i])
    return

if __name__ == "__main__":
    n = int(input())
    a = [int(input()) for _ in range(n)]
    g = []
    cnt = [0]
    m = [0]
    shellSort(a,n)
    print(m[0])
    print(" ".join(map(str,g[::-1])))
    print(cnt[0])
    print("\n".join(map(str,a)))
