def insertionSort(A, g, count):
    N = len(A)
    for i in range(g, N):
        j = i - g
        temp = A[i]
        while j >= 0 and A[j] > temp:
            A[j + g] = A[j]
            j -= g
            count += 1
        A[j + g] = temp
    return A, count


def shellSort(A):
    n = len(A)
    count = 0
    h = 1
    G = []
    while (True):
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
    m = len(G)
    G.reverse()
    for i in range(m):
        A, count = insertionSort(A, G[i], count)
    return m, G, count, A


def listFromInput():
    N = int(input())
    numbers = []
    for i in range(N):
        numbers.append(int(input()))
    return numbers


A = listFromInput()
m, G, count, A = shellSort(A)
print(m)
print(" ".join(list(map(str, G))))
print(count)
for i in A:
    print(i) def insertionSort(A, g, count):
    N = len(A)
    for i in range(g, N):
        j = i - g
        temp = A[i]
        while j >= 0 and A[j] > temp:
            A[j + g] = A[j]
            j -= g
            count += 1
        A[j + g] = temp
    return A, count insertionSort N = len(A) N len(A) len A for i in range(g, N):
        j = i - g
        temp = A[i]
        while j >= 0 and A[j] > temp:
            A[j + g] = A[j]
            j -= g
            count += 1
        A[j + g] = temp
     i range(g, N) range g N j = i - g j i - g i g temp = A[i] temp A[i] A i while j >= 0 and A[j] > temp:
            A[j + g] = A[j]
            j -= g
            count += 1
         j >= 0 and A[j] > temp j >= 0 j 0 A[j] > temp A[j] A j temp A[j + g] = A[j] A[j + g] A j + g j g A[j] A j j -= g j g count += 1 count 1 A[j + g] = temp A[j + g] A j + g j g temp return A, count return A, count A count A A g g count count def shellSort(A):
    n = len(A)
    count = 0
    h = 1
    G = []
    while (True):
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
    m = len(G)
    G.reverse()
    for i in range(m):
        A, count = insertionSort(A, G[i], count)
    return m, G, count, A shellSort n = len(A) n len(A) len A count = 0 count 0 h = 1 h 1 G = [] G [] while (True):
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
     True if h > n:
            break
         h > n h n break G.append(h) G.append G append h h = 3 * h + 1 h 3 * h + 1 3 * h 3 h 1 m = len(G) m len(G) len G G.reverse() G.reverse G reverse for i in range(m):
        A, count = insertionSort(A, G[i], count)
     i range(m) range m A, count = insertionSort(A, G[i], count) A insertionSort(A, G[i], count) insertionSort A G[i] G i count count return m, G, count, A return m, G, count, A m G count A A A def listFromInput():
    N = int(input())
    numbers = []
    for i in range(N):
        numbers.append(int(input()))
    return numbers listFromInput N = int(input()) N int(input()) int input() input numbers = [] numbers [] for i in range(N):
        numbers.append(int(input()))
     i range(N) range N numbers.append(int(input())) numbers.append numbers append int(input()) int input() input return numbers numbers A = listFromInput() A listFromInput() listFromInput m, G, count, A = shellSort(A) m shellSort(A) shellSort A G count A print(m) print m print(" ".join(list(map(str, G)))) print " ".join(list(map(str, G))) " ".join " " join list(map(str, G)) list map(str, G) map str G print(count) print count for i in A:
    print(i) i A print(i) print i A = listFromInput() listFromInput() A G, count, A = shellSort(A) shellSort(A) G def insertionSort(A, g, count):
    N = len(A)
    for i in range(g, N):
        j = i - g
        temp = A[i]
        while j >= 0 and A[j] > temp:
            A[j + g] = A[j]
            j -= g
            count += 1
        A[j + g] = temp
    return A, count def insertionSort(A, g, count):
    N = len(A)
    for i in range(g, N):
        j = i - g
        temp = A[i]
        while j >= 0 and A[j] > temp:
            A[j + g] = A[j]
            j -= g
            count += 1
        A[j + g] = temp
    return A, count insertionSort m, G, count, A = shellSort(A) shellSort(A) m count, A = shellSort(A) shellSort(A) count def shellSort(A):
    n = len(A)
    count = 0
    h = 1
    G = []
    while (True):
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
    m = len(G)
    G.reverse()
    for i in range(m):
        A, count = insertionSort(A, G[i], count)
    return m, G, count, A def shellSort(A):
    n = len(A)
    count = 0
    h = 1
    G = []
    while (True):
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
    m = len(G)
    G.reverse()
    for i in range(m):
        A, count = insertionSort(A, G[i], count)
    return m, G, count, A shellSort def listFromInput():
    N = int(input())
    numbers = []
    for i in range(N):
        numbers.append(int(input()))
    return numbers def listFromInput():
    N = int(input())
    numbers = []
    for i in range(N):
        numbers.append(int(input()))
    return numbers listFromInput A = shellSort(A) shellSort(A) A
def insertionSort(A, g, count):
    N = len(A)
    for i in range(g, N):
        j = i - g
        temp = A[i]
        while j >= 0 and A[j] > temp:
            A[j + g] = A[j]
            j -= g
            count += 1
        A[j + g] = temp
    return A, count


def shellSort(A):
    n = len(A)
    count = 0
    h = 1
    G = []
    while (True):
        if h > n:
            break
        G.append(h)
        h = 3 * h + 1
    m = len(G)
    G.reverse()
    for i in range(m):
        A, count = insertionSort(A, G[i], count)
    return m, G, count, A


def listFromInput():
    N = int(input())
    numbers = []
    for i in range(N):
        numbers.append(int(input()))
    return numbers


A = listFromInput()
m, G, count, A = shellSort(A)
print(m)
print(" ".join(list(map(str, G))))
print(count)
for i in A:
    print(i)