def insertion_sort(array, size, gap=1):
    """ AOJ??¬??¶?????¬???
    http://judge.u-aizu.ac.jp/onlinejudge/commentary.jsp?id=ALDS1_1_A

    :param array: ?????????????±??????????
    :return: ?????????????????????
    """
    global Count

    for i in range(gap, len(array)):  # i????¬??????????????????????????????????
        v = array[i]  # ?????¨?????\???????????¨????????????????????????????????´???
        j = i - gap
        while j >= 0 and array[j] > v:
            array[j + gap] = array[j]
            j = j - gap
            Count += 1
        array[j + gap] = v
    return array

def shell_sort(array, n):
    Count = 0
    G = calc_gap(n)
    m = len(G)
    print(m)
    print(' '.join(map(str, G)))
    for i in range(0, m):
        insertion_sort(array, n, G[i])


def calc_gap(n):
    results = [1]
    while results[-1] < n:
        results.append(3 * results[-1] + 1)
    if len(results) > 1:
        results = results[:-1]
    results.sort(reverse=True)
    return results


Count = 0
if __name__ == '__main__':
    # ??????????????\???
    # data = [5, 1, 4, 3, 2]
    data = []
    num = int(input())
    for i in range(num):
        data.append(int(input()))

    # ???????????????
    shell_sort(data, len(data))

    # ???????????¨???
    print(Count)
    for i in data:
        print(i) def insertion_sort(array, size, gap=1):
    """ AOJ??¬??¶?????¬???
    http://judge.u-aizu.ac.jp/onlinejudge/commentary.jsp?id=ALDS1_1_A

    :param array: ?????????????±??????????
    :return: ?????????????????????
    """
    global Count

    for i in range(gap, len(array)):  # i????¬??????????????????????????????????
        v = array[i]  # ?????¨?????\???????????¨????????????????????????????????´???
        j = i - gap
        while j >= 0 and array[j] > v:
            array[j + gap] = array[j]
            j = j - gap
            Count += 1
        array[j + gap] = v
    return array insertion_sort """ AOJ??¬??¶?????¬???
    http://judge.u-aizu.ac.jp/onlinejudge/commentary.jsp?id=ALDS1_1_A

    :param array: ?????????????±??????????
    :return: ?????????????????????
    """ global Count for i in range(gap, len(array)):  # i????¬??????????????????????????????????
        v = array[i]  # ?????¨?????\???????????¨????????????????????????????????´???
        j = i - gap
        while j >= 0 and array[j] > v:
            array[j + gap] = array[j]
            j = j - gap
            Count += 1
        array[j + gap] = v
     i range(gap, len(array)) range gap len(array) len array v = array[i] v array[i] array i j = i - gap j i - gap i gap while j >= 0 and array[j] > v:
            array[j + gap] = array[j]
            j = j - gap
            Count += 1
         j >= 0 and array[j] > v j >= 0 j 0 array[j] > v array[j] array j v array[j + gap] = array[j] array[j + gap] array j + gap j gap array[j] array j j = j - gap j j - gap j gap Count += 1 Count 1 array[j + gap] = v array[j + gap] array j + gap j gap v return array array array array size size gap=1 gap 1 def shell_sort(array, n):
    Count = 0
    G = calc_gap(n)
    m = len(G)
    print(m)
    print(' '.join(map(str, G)))
    for i in range(0, m):
        insertion_sort(array, n, G[i]) shell_sort Count = 0 Count 0 G = calc_gap(n) G calc_gap(n) calc_gap n m = len(G) m len(G) len G print(m) print m print(' '.join(map(str, G))) print ' '.join(map(str, G)) ' '.join ' ' join map(str, G) map str G for i in range(0, m):
        insertion_sort(array, n, G[i]) i range(0, m) range 0 m insertion_sort(array, n, G[i]) insertion_sort array n G[i] G i array array n n def calc_gap(n):
    results = [1]
    while results[-1] < n:
        results.append(3 * results[-1] + 1)
    if len(results) > 1:
        results = results[:-1]
    results.sort(reverse=True)
    return results calc_gap results = [1] results [1] 1 while results[-1] < n:
        results.append(3 * results[-1] + 1)
     results[-1] < n results[-1] results -1 n results.append(3 * results[-1] + 1) results.append results append 3 * results[-1] + 1 3 * results[-1] 3 results[-1] results -1 1 if len(results) > 1:
        results = results[:-1]
     len(results) > 1 len(results) len results 1 results = results[:-1] results results[:-1] results :-1 -1 results.sort(reverse=True) results.sort results sort reverse=True reverse True return results results n n Count = 0 Count 0 if __name__ == '__main__':
    # ??????????????\???
    # data = [5, 1, 4, 3, 2]
    data = []
    num = int(input())
    for i in range(num):
        data.append(int(input()))

    # ???????????????
    shell_sort(data, len(data))

    # ???????????¨???
    print(Count)
    for i in data:
        print(i) __name__ == '__main__' __name__ '__main__' data = [] data [] num = int(input()) num int(input()) int input() input for i in range(num):
        data.append(int(input()))

    # ???????????????
     i range(num) range num data.append(int(input())) data.append data append int(input()) int input() input shell_sort(data, len(data)) shell_sort data len(data) len data print(Count) print Count for i in data:
        print(i) i data print(i) print i def insertion_sort(array, size, gap=1):
    """ AOJ??¬??¶?????¬???
    http://judge.u-aizu.ac.jp/onlinejudge/commentary.jsp?id=ALDS1_1_A

    :param array: ?????????????±??????????
    :return: ?????????????????????
    """
    global Count

    for i in range(gap, len(array)):  # i????¬??????????????????????????????????
        v = array[i]  # ?????¨?????\???????????¨????????????????????????????????´???
        j = i - gap
        while j >= 0 and array[j] > v:
            array[j + gap] = array[j]
            j = j - gap
            Count += 1
        array[j + gap] = v
    return array def insertion_sort(array, size, gap=1):
    """ AOJ??¬??¶?????¬???
    http://judge.u-aizu.ac.jp/onlinejudge/commentary.jsp?id=ALDS1_1_A

    :param array: ?????????????±??????????
    :return: ?????????????????????
    """
    global Count

    for i in range(gap, len(array)):  # i????¬??????????????????????????????????
        v = array[i]  # ?????¨?????\???????????¨????????????????????????????????´???
        j = i - gap
        while j >= 0 and array[j] > v:
            array[j + gap] = array[j]
            j = j - gap
            Count += 1
        array[j + gap] = v
    return array insertion_sort Count = 0 0 Count num = int(input()) int(input()) num def shell_sort(array, n):
    Count = 0
    G = calc_gap(n)
    m = len(G)
    print(m)
    print(' '.join(map(str, G)))
    for i in range(0, m):
        insertion_sort(array, n, G[i]) def shell_sort(array, n):
    Count = 0
    G = calc_gap(n)
    m = len(G)
    print(m)
    print(' '.join(map(str, G)))
    for i in range(0, m):
        insertion_sort(array, n, G[i]) shell_sort def calc_gap(n):
    results = [1]
    while results[-1] < n:
        results.append(3 * results[-1] + 1)
    if len(results) > 1:
        results = results[:-1]
    results.sort(reverse=True)
    return results def calc_gap(n):
    results = [1]
    while results[-1] < n:
        results.append(3 * results[-1] + 1)
    if len(results) > 1:
        results = results[:-1]
    results.sort(reverse=True)
    return results calc_gap data = [] [] data
def insertion_sort(array, size, gap=1):
    """ AOJ??¬??¶?????¬???
    http://judge.u-aizu.ac.jp/onlinejudge/commentary.jsp?id=ALDS1_1_A

    :param array: ?????????????±??????????
    :return: ?????????????????????
    """
    global Count

    for i in range(gap, len(array)):  # i????¬??????????????????????????????????
        v = array[i]  # ?????¨?????\???????????¨????????????????????????????????´???
        j = i - gap
        while j >= 0 and array[j] > v:
            array[j + gap] = array[j]
            j = j - gap
            Count += 1
        array[j + gap] = v
    return array

def shell_sort(array, n):
    Count = 0
    G = calc_gap(n)
    m = len(G)
    print(m)
    print(' '.join(map(str, G)))
    for i in range(0, m):
        insertion_sort(array, n, G[i])


def calc_gap(n):
    results = [1]
    while results[-1] < n:
        results.append(3 * results[-1] + 1)
    if len(results) > 1:
        results = results[:-1]
    results.sort(reverse=True)
    return results


Count = 0
if __name__ == '__main__':
    # ??????????????\???
    # data = [5, 1, 4, 3, 2]
    data = []
    num = int(input())
    for i in range(num):
        data.append(int(input()))

    # ???????????????
    shell_sort(data, len(data))

    # ???????????¨???
    print(Count)
    for i in data:
        print(i)