def insertion_sort(numbers, n, g):
    """insertion sort method
    (only elements whose distance is larger than g are the target)

    Args:
        numbers: list of elements to be sorted
        n: len(numbers)
        g: distance

    Returns:
        partially sorted list, counter
    """
    counter = 0
    copied_instance = []
    for data in numbers:
        copied_instance.append(data)

    for i in range(g, n):
        target = copied_instance[i]
        j = i - g
        while j >= 0 and target < copied_instance[j]:
            copied_instance[j + g] = copied_instance[j]
            j -= g
            counter += 1
        copied_instance[j + g] = target
    return copied_instance, counter


def shell_sort(numbers, n, key=lambda x: x):
    """shell sort method

    Args:
        numbers: list of elements to be sorted
        n: len(numbers)

    Returns:
        sorted numbers, used G, swapped number
    """
    counter = 0
    copied_instance = []
    for data in numbers:
        copied_instance.append(data)

    G = [1]
    g = 4
    while g < len(numbers):
        G.append(g)
        g = g * 3 + 1
    G = G[::-1]
    for g in G:
        copied_instance, num = insertion_sort(copied_instance, n, g)
        counter += num

    return copied_instance, G, counter


length = int(raw_input())
numbers = []
counter = 0
while counter < length:
    numbers.append(int(raw_input()))
    counter += 1

numbers, G, counter = shell_sort(numbers, length)
print(len(G))
print(" ".join([str(x) for x in G]))
print(counter)
for n in numbers:
    print(str(n)) def insertion_sort(numbers, n, g):
    """insertion sort method
    (only elements whose distance is larger than g are the target)

    Args:
        numbers: list of elements to be sorted
        n: len(numbers)
        g: distance

    Returns:
        partially sorted list, counter
    """
    counter = 0
    copied_instance = []
    for data in numbers:
        copied_instance.append(data)

    for i in range(g, n):
        target = copied_instance[i]
        j = i - g
        while j >= 0 and target < copied_instance[j]:
            copied_instance[j + g] = copied_instance[j]
            j -= g
            counter += 1
        copied_instance[j + g] = target
    return copied_instance, counter insertion_sort """insertion sort method
    (only elements whose distance is larger than g are the target)

    Args:
        numbers: list of elements to be sorted
        n: len(numbers)
        g: distance

    Returns:
        partially sorted list, counter
    """ counter = 0 counter 0 copied_instance = [] copied_instance [] for data in numbers:
        copied_instance.append(data)

     data numbers copied_instance.append(data) copied_instance.append copied_instance append data for i in range(g, n):
        target = copied_instance[i]
        j = i - g
        while j >= 0 and target < copied_instance[j]:
            copied_instance[j + g] = copied_instance[j]
            j -= g
            counter += 1
        copied_instance[j + g] = target
     i range(g, n) range g n target = copied_instance[i] target copied_instance[i] copied_instance i j = i - g j i - g i g while j >= 0 and target < copied_instance[j]:
            copied_instance[j + g] = copied_instance[j]
            j -= g
            counter += 1
         j >= 0 and target < copied_instance[j] j >= 0 j 0 target < copied_instance[j] target copied_instance[j] copied_instance j copied_instance[j + g] = copied_instance[j] copied_instance[j + g] copied_instance j + g j g copied_instance[j] copied_instance j j -= g j g counter += 1 counter 1 copied_instance[j + g] = target copied_instance[j + g] copied_instance j + g j g target return copied_instance, counter return copied_instance, counter copied_instance counter numbers numbers n n g g def shell_sort(numbers, n, key=lambda x: x):
    """shell sort method

    Args:
        numbers: list of elements to be sorted
        n: len(numbers)

    Returns:
        sorted numbers, used G, swapped number
    """
    counter = 0
    copied_instance = []
    for data in numbers:
        copied_instance.append(data)

    G = [1]
    g = 4
    while g < len(numbers):
        G.append(g)
        g = g * 3 + 1
    G = G[::-1]
    for g in G:
        copied_instance, num = insertion_sort(copied_instance, n, g)
        counter += num

    return copied_instance, G, counter shell_sort """shell sort method

    Args:
        numbers: list of elements to be sorted
        n: len(numbers)

    Returns:
        sorted numbers, used G, swapped number
    """ counter = 0 counter 0 copied_instance = [] copied_instance [] for data in numbers:
        copied_instance.append(data)

     data numbers copied_instance.append(data) copied_instance.append copied_instance append data G = [1] G [1] 1 g = 4 g 4 while g < len(numbers):
        G.append(g)
        g = g * 3 + 1
     g < len(numbers) g len(numbers) len numbers G.append(g) G.append G append g g = g * 3 + 1 g g * 3 + 1 g * 3 g 3 1 G = G[::-1] G G[::-1] G ::-1 -1 for g in G:
        copied_instance, num = insertion_sort(copied_instance, n, g)
        counter += num

     g G copied_instance, num = insertion_sort(copied_instance, n, g) copied_instance insertion_sort(copied_instance, n, g) insertion_sort copied_instance n g num counter += num counter num return copied_instance, G, counter return copied_instance, G, counter copied_instance G counter numbers numbers n n key=lambda x: x key lambda x: x x x length = int(raw_input()) length int(raw_input()) int raw_input() raw_input numbers = [] numbers [] counter = 0 counter 0 while counter < length:
    numbers.append(int(raw_input()))
    counter += 1 counter < length counter length numbers.append(int(raw_input())) numbers.append numbers append int(raw_input()) int raw_input() raw_input counter += 1 counter 1 numbers, G, counter = shell_sort(numbers, length) numbers shell_sort(numbers, length) shell_sort numbers length G counter print(len(G)) print len(G) len G str(x) for x in G for x in G x G for x in G str(x) str x print(" ".join([str(x) for x in G])) print " ".join([str(x) for x in G]) " ".join " " join [str(x) for x in G] print(counter) print counter for n in numbers:
    print(str(n)) n numbers print(str(n)) print str(n) str n G, counter = shell_sort(numbers, length) shell_sort(numbers, length) G counter += 1 1 counter counter = 0 0 counter length = int(raw_input()) int(raw_input()) length numbers, G, counter = shell_sort(numbers, length) shell_sort(numbers, length) numbers counter = shell_sort(numbers, length) shell_sort(numbers, length) counter def insertion_sort(numbers, n, g):
    """insertion sort method
    (only elements whose distance is larger than g are the target)

    Args:
        numbers: list of elements to be sorted
        n: len(numbers)
        g: distance

    Returns:
        partially sorted list, counter
    """
    counter = 0
    copied_instance = []
    for data in numbers:
        copied_instance.append(data)

    for i in range(g, n):
        target = copied_instance[i]
        j = i - g
        while j >= 0 and target < copied_instance[j]:
            copied_instance[j + g] = copied_instance[j]
            j -= g
            counter += 1
        copied_instance[j + g] = target
    return copied_instance, counter def insertion_sort(numbers, n, g):
    """insertion sort method
    (only elements whose distance is larger than g are the target)

    Args:
        numbers: list of elements to be sorted
        n: len(numbers)
        g: distance

    Returns:
        partially sorted list, counter
    """
    counter = 0
    copied_instance = []
    for data in numbers:
        copied_instance.append(data)

    for i in range(g, n):
        target = copied_instance[i]
        j = i - g
        while j >= 0 and target < copied_instance[j]:
            copied_instance[j + g] = copied_instance[j]
            j -= g
            counter += 1
        copied_instance[j + g] = target
    return copied_instance, counter insertion_sort def shell_sort(numbers, n, key=lambda x: x):
    """shell sort method

    Args:
        numbers: list of elements to be sorted
        n: len(numbers)

    Returns:
        sorted numbers, used G, swapped number
    """
    counter = 0
    copied_instance = []
    for data in numbers:
        copied_instance.append(data)

    G = [1]
    g = 4
    while g < len(numbers):
        G.append(g)
        g = g * 3 + 1
    G = G[::-1]
    for g in G:
        copied_instance, num = insertion_sort(copied_instance, n, g)
        counter += num

    return copied_instance, G, counter def shell_sort(numbers, n, key=lambda x: x):
    """shell sort method

    Args:
        numbers: list of elements to be sorted
        n: len(numbers)

    Returns:
        sorted numbers, used G, swapped number
    """
    counter = 0
    copied_instance = []
    for data in numbers:
        copied_instance.append(data)

    G = [1]
    g = 4
    while g < len(numbers):
        G.append(g)
        g = g * 3 + 1
    G = G[::-1]
    for g in G:
        copied_instance, num = insertion_sort(copied_instance, n, g)
        counter += num

    return copied_instance, G, counter shell_sort numbers = [] [] numbers
def insertion_sort(numbers, n, g):
    """insertion sort method
    (only elements whose distance is larger than g are the target)

    Args:
        numbers: list of elements to be sorted
        n: len(numbers)
        g: distance

    Returns:
        partially sorted list, counter
    """
    counter = 0
    copied_instance = []
    for data in numbers:
        copied_instance.append(data)

    for i in range(g, n):
        target = copied_instance[i]
        j = i - g
        while j >= 0 and target < copied_instance[j]:
            copied_instance[j + g] = copied_instance[j]
            j -= g
            counter += 1
        copied_instance[j + g] = target
    return copied_instance, counter


def shell_sort(numbers, n, key=lambda x: x):
    """shell sort method

    Args:
        numbers: list of elements to be sorted
        n: len(numbers)

    Returns:
        sorted numbers, used G, swapped number
    """
    counter = 0
    copied_instance = []
    for data in numbers:
        copied_instance.append(data)

    G = [1]
    g = 4
    while g < len(numbers):
        G.append(g)
        g = g * 3 + 1
    G = G[::-1]
    for g in G:
        copied_instance, num = insertion_sort(copied_instance, n, g)
        counter += num

    return copied_instance, G, counter


length = int(raw_input())
numbers = []
counter = 0
while counter < length:
    numbers.append(int(raw_input()))
    counter += 1

numbers, G, counter = shell_sort(numbers, length)
print(len(G))
print(" ".join([str(x) for x in G]))
print(counter)
for n in numbers:
    print(str(n))