# ALDS1_2_D: Shell Sort

#N = 5
#A = [5, 1, 4, 3, 2]

#N = 3
#A = [3, 2, 1]

A = []
N = int(input())
for i in range(N):
    A.append(int(input()))

def insertionSort(A, N, g, cnt):
    #print(" ".join(map(str, A)))
    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 += 1
        A[j+g] = v
        #print(" ".join(map(str, A)))
    return cnt
    
def shellSort(A, N):
    cnt = 0
    #m = 2
    #listG = [4, 1] 
    h = 1
    listG = []
    while h <= N:
        listG.append(h)
        h = 3*h + 1
    listG = listG[::-1]
    m = len(listG)
    
    for g in listG:
        cnt = insertionSort(A, N, g, cnt)
        #print(A)
        
    print(m)
    print(" ".join(map(str, listG)))
    print(cnt)
    for v in A:
        print(v)

shellSort(A, N) 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 def insertionSort(A, N, g, cnt):
    #print(" ".join(map(str, A)))
    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 += 1
        A[j+g] = v
        #print(" ".join(map(str, A)))
    return cnt
     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 += 1
        A[j+g] = v
        #print(" ".join(map(str, A)))
     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 += 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 return cnt cnt A A N N g g cnt cnt def shellSort(A, N):
    cnt = 0
    #m = 2
    #listG = [4, 1] 
    h = 1
    listG = []
    while h <= N:
        listG.append(h)
        h = 3*h + 1
    listG = listG[::-1]
    m = len(listG)
    
    for g in listG:
        cnt = insertionSort(A, N, g, cnt)
        #print(A)
        
    print(m)
    print(" ".join(map(str, listG)))
    print(cnt)
    for v in A:
        print(v) shellSort cnt = 0 cnt 0 h = 1 h 1 listG = [] listG [] while h <= N:
        listG.append(h)
        h = 3*h + 1
     h <= N h N listG.append(h) listG.append listG append h h = 3*h + 1 h 3*h + 1 3*h 3 h 1 listG = listG[::-1] listG listG[::-1] listG ::-1 -1 m = len(listG) m len(listG) len listG for g in listG:
        cnt = insertionSort(A, N, g, cnt)
        #print(A)
        
     g listG cnt = insertionSort(A, N, g, cnt) cnt insertionSort(A, N, g, cnt) insertionSort A N g cnt print(m) print m print(" ".join(map(str, listG))) print " ".join(map(str, listG)) " ".join " " join map(str, listG) map str listG print(cnt) print cnt for v in A:
        print(v) v A print(v) print v A A N N shellSort(A, N) shellSort A N def shellSort(A, N):
    cnt = 0
    #m = 2
    #listG = [4, 1] 
    h = 1
    listG = []
    while h <= N:
        listG.append(h)
        h = 3*h + 1
    listG = listG[::-1]
    m = len(listG)
    
    for g in listG:
        cnt = insertionSort(A, N, g, cnt)
        #print(A)
        
    print(m)
    print(" ".join(map(str, listG)))
    print(cnt)
    for v in A:
        print(v) def shellSort(A, N):
    cnt = 0
    #m = 2
    #listG = [4, 1] 
    h = 1
    listG = []
    while h <= N:
        listG.append(h)
        h = 3*h + 1
    listG = listG[::-1]
    m = len(listG)
    
    for g in listG:
        cnt = insertionSort(A, N, g, cnt)
        #print(A)
        
    print(m)
    print(" ".join(map(str, listG)))
    print(cnt)
    for v in A:
        print(v) shellSort A = [] [] A def insertionSort(A, N, g, cnt):
    #print(" ".join(map(str, A)))
    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 += 1
        A[j+g] = v
        #print(" ".join(map(str, A)))
    return cnt
     def insertionSort(A, N, g, cnt):
    #print(" ".join(map(str, A)))
    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 += 1
        A[j+g] = v
        #print(" ".join(map(str, A)))
    return cnt
     insertionSort N = int(input()) int(input()) N
# ALDS1_2_D: Shell Sort

#N = 5
#A = [5, 1, 4, 3, 2]

#N = 3
#A = [3, 2, 1]

A = []
N = int(input())
for i in range(N):
    A.append(int(input()))

def insertionSort(A, N, g, cnt):
    #print(" ".join(map(str, A)))
    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 += 1
        A[j+g] = v
        #print(" ".join(map(str, A)))
    return cnt
    
def shellSort(A, N):
    cnt = 0
    #m = 2
    #listG = [4, 1] 
    h = 1
    listG = []
    while h <= N:
        listG.append(h)
        h = 3*h + 1
    listG = listG[::-1]
    m = len(listG)
    
    for g in listG:
        cnt = insertionSort(A, N, g, cnt)
        #print(A)
        
    print(m)
    print(" ".join(map(str, listG)))
    print(cnt)
    for v in A:
        print(v)

shellSort(A, N)
