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


def insertionSort(N,A,g):
    global cnt
    for i in range(g,N):
        v = A[i]
        j = i-g
        while A[j] > v and j >= 0:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return A    
      
def shellSort(N,A):
    global cnt
    cnt = 0
    m = 1
    G = [1]
    x = 1
    for i in range(N):
        x = 3*x + 1
        if x > N:
            break
        G.insert(0,x)
        m += 1
    
    for i in range(m):
        A = insertionSort(N,A,G[i])
    
    return cnt,A,m,G

cnt,A,m,G = shellSort(N,A)
print(m)
print(" ".join([str(g) for g in G]))
print(cnt)
for i in range(len(A)):
    print(A[i])
        
        
         N = int(input()) N int(input()) int input() input A = [] A [] 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(N,A,g):
    global cnt
    for i in range(g,N):
        v = A[i]
        j = i-g
        while A[j] > v and j >= 0:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return A    
       insertionSort global cnt for i in range(g,N):
        v = A[i]
        j = i-g
        while A[j] > v and j >= 0:
            A[j+g] = A[j]
            j -= g
            cnt += 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 A[j] > v and j >= 0:
            A[j+g] = A[j]
            j -= g
            cnt += 1
         A[j] > v and j >= 0 A[j] > v A[j] A j v j >= 0 j 0 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 A N N A A g g def shellSort(N,A):
    global cnt
    cnt = 0
    m = 1
    G = [1]
    x = 1
    for i in range(N):
        x = 3*x + 1
        if x > N:
            break
        G.insert(0,x)
        m += 1
    
    for i in range(m):
        A = insertionSort(N,A,G[i])
    
    return cnt,A,m,G shellSort global cnt cnt = 0 cnt 0 m = 1 m 1 G = [1] G [1] 1 x = 1 x 1 for i in range(N):
        x = 3*x + 1
        if x > N:
            break
        G.insert(0,x)
        m += 1
    
     i range(N) range N x = 3*x + 1 x 3*x + 1 3*x 3 x 1 if x > N:
            break
         x > N x N break G.insert(0,x) G.insert G insert 0 x m += 1 m 1 for i in range(m):
        A = insertionSort(N,A,G[i])
    
     i range(m) range m A = insertionSort(N,A,G[i]) A insertionSort(N,A,G[i]) insertionSort N A G[i] G i return cnt,A,m,G return cnt,A,m,G cnt A m G N N A A cnt,A,m,G = shellSort(N,A) cnt shellSort(N,A) shellSort N A A m G print(m) print m str(g) for g in G for g in G g G for g in G str(g) str g print(" ".join([str(g) for g in G])) print " ".join([str(g) for g in G]) " ".join " " join [str(g) for g in G] print(cnt) print cnt for i in range(len(A)):
    print(A[i])
        
        
         i range(len(A)) range len(A) len A print(A[i]) print A[i] A i N = int(input()) int(input()) N cnt,A,m,G = shellSort(N,A) shellSort(N,A) cnt A = [] [] A def insertionSort(N,A,g):
    global cnt
    for i in range(g,N):
        v = A[i]
        j = i-g
        while A[j] > v and j >= 0:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return A    
       def insertionSort(N,A,g):
    global cnt
    for i in range(g,N):
        v = A[i]
        j = i-g
        while A[j] > v and j >= 0:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return A    
       insertionSort G = shellSort(N,A) shellSort(N,A) G def shellSort(N,A):
    global cnt
    cnt = 0
    m = 1
    G = [1]
    x = 1
    for i in range(N):
        x = 3*x + 1
        if x > N:
            break
        G.insert(0,x)
        m += 1
    
    for i in range(m):
        A = insertionSort(N,A,G[i])
    
    return cnt,A,m,G def shellSort(N,A):
    global cnt
    cnt = 0
    m = 1
    G = [1]
    x = 1
    for i in range(N):
        x = 3*x + 1
        if x > N:
            break
        G.insert(0,x)
        m += 1
    
    for i in range(m):
        A = insertionSort(N,A,G[i])
    
    return cnt,A,m,G shellSort A,m,G = shellSort(N,A) shellSort(N,A) A m,G = shellSort(N,A) shellSort(N,A) m
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))


def insertionSort(N,A,g):
    global cnt
    for i in range(g,N):
        v = A[i]
        j = i-g
        while A[j] > v and j >= 0:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v
    return A    
      
def shellSort(N,A):
    global cnt
    cnt = 0
    m = 1
    G = [1]
    x = 1
    for i in range(N):
        x = 3*x + 1
        if x > N:
            break
        G.insert(0,x)
        m += 1
    
    for i in range(m):
        A = insertionSort(N,A,G[i])
    
    return cnt,A,m,G

cnt,A,m,G = shellSort(N,A)
print(m)
print(" ".join([str(g) for g in G]))
print(cnt)
for i in range(len(A)):
    print(A[i])
        
        
        
