def insertion_sort(a, n, g, cnt):
    for i in range(g,n,1):
        v = a[i]
        j = i - g #initial value
        while j>=0 and a[j]>v:
            a[j+g]=a[j]
            j -= g
            cnt += 1
        a[j+g] = v
    return a, cnt

def shell_sort(a,n,m,g):
    cnt = 0
    for i in range(m):
        sorted_list, cnt = insertion_sort(a,n,g[i],cnt)
    return sorted_list, cnt

def seqforshell(n):
    seq = [1]
    next_num = 3*seq[0] + 1
    while next_num<n:
        seq.insert(0, next_num)
        next_num = 3*next_num + 1
    return seq

if __name__ == "__main__":
    a = []
    n = int(input())
    for i in range(n):
        a.append(int(input()))
    
    g = seqforshell(n)
    m = len(g)
    res, cnt = shell_sort(a,n,m,g)
    
    print(m)
    print(*g)
    print(cnt)
    for i in range(n):
        print(res[i]) def insertion_sort(a, n, g, cnt):
    for i in range(g,n,1):
        v = a[i]
        j = i - g #initial value
        while j>=0 and a[j]>v:
            a[j+g]=a[j]
            j -= g
            cnt += 1
        a[j+g] = v
    return a, cnt insertion_sort for i in range(g,n,1):
        v = a[i]
        j = i - g #initial value
        while j>=0 and a[j]>v:
            a[j+g]=a[j]
            j -= g
            cnt += 1
        a[j+g] = v
     i range(g,n,1) range g n 1 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 -= 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 -= g j g cnt += 1 cnt 1 a[j+g] = v a[j+g] a j+g j g v return a, cnt return a, cnt a cnt a a n n g g cnt cnt def shell_sort(a,n,m,g):
    cnt = 0
    for i in range(m):
        sorted_list, cnt = insertion_sort(a,n,g[i],cnt)
    return sorted_list, cnt shell_sort cnt = 0 cnt 0 for i in range(m):
        sorted_list, cnt = insertion_sort(a,n,g[i],cnt)
     i range(m) range m sorted_list, cnt = insertion_sort(a,n,g[i],cnt) sorted_list insertion_sort(a,n,g[i],cnt) insertion_sort a n g[i] g i cnt cnt return sorted_list, cnt return sorted_list, cnt sorted_list cnt a a n n m m g g def seqforshell(n):
    seq = [1]
    next_num = 3*seq[0] + 1
    while next_num<n:
        seq.insert(0, next_num)
        next_num = 3*next_num + 1
    return seq seqforshell seq = [1] seq [1] 1 next_num = 3*seq[0] + 1 next_num 3*seq[0] + 1 3*seq[0] 3 seq[0] seq 0 1 while next_num<n:
        seq.insert(0, next_num)
        next_num = 3*next_num + 1
     next_num<n next_num n seq.insert(0, next_num) seq.insert seq insert 0 next_num next_num = 3*next_num + 1 next_num 3*next_num + 1 3*next_num 3 next_num 1 return seq seq n n if __name__ == "__main__":
    a = []
    n = int(input())
    for i in range(n):
        a.append(int(input()))
    
    g = seqforshell(n)
    m = len(g)
    res, cnt = shell_sort(a,n,m,g)
    
    print(m)
    print(*g)
    print(cnt)
    for i in range(n):
        print(res[i]) __name__ == "__main__" __name__ "__main__" a = [] a [] n = int(input()) n int(input()) int input() input for i in range(n):
        a.append(int(input()))
    
     i range(n) range n a.append(int(input())) a.append a append int(input()) int input() input g = seqforshell(n) g seqforshell(n) seqforshell n m = len(g) m len(g) len g res, cnt = shell_sort(a,n,m,g) res shell_sort(a,n,m,g) shell_sort a n m g cnt print(m) print m print(*g) print *g g print(cnt) print cnt for i in range(n):
        print(res[i]) i range(n) range n print(res[i]) print res[i] res i def shell_sort(a,n,m,g):
    cnt = 0
    for i in range(m):
        sorted_list, cnt = insertion_sort(a,n,g[i],cnt)
    return sorted_list, cnt def shell_sort(a,n,m,g):
    cnt = 0
    for i in range(m):
        sorted_list, cnt = insertion_sort(a,n,g[i],cnt)
    return sorted_list, cnt shell_sort def seqforshell(n):
    seq = [1]
    next_num = 3*seq[0] + 1
    while next_num<n:
        seq.insert(0, next_num)
        next_num = 3*next_num + 1
    return seq def seqforshell(n):
    seq = [1]
    next_num = 3*seq[0] + 1
    while next_num<n:
        seq.insert(0, next_num)
        next_num = 3*next_num + 1
    return seq seqforshell def insertion_sort(a, n, g, cnt):
    for i in range(g,n,1):
        v = a[i]
        j = i - g #initial value
        while j>=0 and a[j]>v:
            a[j+g]=a[j]
            j -= g
            cnt += 1
        a[j+g] = v
    return a, cnt def insertion_sort(a, n, g, cnt):
    for i in range(g,n,1):
        v = a[i]
        j = i - g #initial value
        while j>=0 and a[j]>v:
            a[j+g]=a[j]
            j -= g
            cnt += 1
        a[j+g] = v
    return a, cnt insertion_sort g = seqforshell(n) seqforshell(n) g n = int(input()) int(input()) n m = len(g) len(g) m res, cnt = shell_sort(a,n,m,g) shell_sort(a,n,m,g) res a = [] [] a cnt = shell_sort(a,n,m,g) shell_sort(a,n,m,g) cnt
def insertion_sort(a, n, g, cnt):
    for i in range(g,n,1):
        v = a[i]
        j = i - g #initial value
        while j>=0 and a[j]>v:
            a[j+g]=a[j]
            j -= g
            cnt += 1
        a[j+g] = v
    return a, cnt

def shell_sort(a,n,m,g):
    cnt = 0
    for i in range(m):
        sorted_list, cnt = insertion_sort(a,n,g[i],cnt)
    return sorted_list, cnt

def seqforshell(n):
    seq = [1]
    next_num = 3*seq[0] + 1
    while next_num<n:
        seq.insert(0, next_num)
        next_num = 3*next_num + 1
    return seq

if __name__ == "__main__":
    a = []
    n = int(input())
    for i in range(n):
        a.append(int(input()))
    
    g = seqforshell(n)
    m = len(g)
    res, cnt = shell_sort(a,n,m,g)
    
    print(m)
    print(*g)
    print(cnt)
    for i in range(n):
        print(res[i])
