#!/usr/bin/env python
# encoding: utf-8

import sys


class Solution:
    def __init__(self):
        self.count = 0

    def shell_sort(self):
        _input = sys.stdin.readlines()
        array_length = int(_input[0])
        array = list(map(int, _input[1:]))

        G = [1]
        while True:
            g = G[0] * 3 + 1
            if g > array_length:
                break
            G.insert(0, g)

        g_length = len(G)
        result = []
        for j in range(g_length):
            result = self.insertion_sort(array=array, array_length=array_length, g=G[j])
            # print(result, 'r', G[j])

        print(g_length)
        print(*G)
        print(self.count)
        print(*result, sep='\n')

    def insertion_sort(self, array, array_length, g):
        # write your code here

        for i in range(g, array_length):
            v = array[i]
            j = i - g
            while j >= 0 and array[j] > v:
                array[j + g] = array[j]
                j -= g
                self.count += 1
            array[j + g] = v

        # print(" ".join(map(str, array)))
        return array


if __name__ == '__main__':
    solution = Solution()
    solution.shell_sort() import sys sys class Solution:
    def __init__(self):
        self.count = 0

    def shell_sort(self):
        _input = sys.stdin.readlines()
        array_length = int(_input[0])
        array = list(map(int, _input[1:]))

        G = [1]
        while True:
            g = G[0] * 3 + 1
            if g > array_length:
                break
            G.insert(0, g)

        g_length = len(G)
        result = []
        for j in range(g_length):
            result = self.insertion_sort(array=array, array_length=array_length, g=G[j])
            # print(result, 'r', G[j])

        print(g_length)
        print(*G)
        print(self.count)
        print(*result, sep='\n')

    def insertion_sort(self, array, array_length, g):
        # write your code here

        for i in range(g, array_length):
            v = array[i]
            j = i - g
            while j >= 0 and array[j] > v:
                array[j + g] = array[j]
                j -= g
                self.count += 1
            array[j + g] = v

        # print(" ".join(map(str, array)))
        return array Solution def __init__(self):
        self.count = 0

     __init__ self.count = 0 self.count self count 0 self self def shell_sort(self):
        _input = sys.stdin.readlines()
        array_length = int(_input[0])
        array = list(map(int, _input[1:]))

        G = [1]
        while True:
            g = G[0] * 3 + 1
            if g > array_length:
                break
            G.insert(0, g)

        g_length = len(G)
        result = []
        for j in range(g_length):
            result = self.insertion_sort(array=array, array_length=array_length, g=G[j])
            # print(result, 'r', G[j])

        print(g_length)
        print(*G)
        print(self.count)
        print(*result, sep='\n')

     shell_sort _input = sys.stdin.readlines() _input sys.stdin.readlines() sys.stdin.readlines sys.stdin sys stdin readlines array_length = int(_input[0]) array_length int(_input[0]) int _input[0] _input 0 array = list(map(int, _input[1:])) array list(map(int, _input[1:])) list map(int, _input[1:]) map int _input[1:] _input 1: 1 G = [1] G [1] 1 while True:
            g = G[0] * 3 + 1
            if g > array_length:
                break
            G.insert(0, g)

         True g = G[0] * 3 + 1 g G[0] * 3 + 1 G[0] * 3 G[0] G 0 3 1 if g > array_length:
                break
             g > array_length g array_length break G.insert(0, g) G.insert G insert 0 g g_length = len(G) g_length len(G) len G result = [] result [] for j in range(g_length):
            result = self.insertion_sort(array=array, array_length=array_length, g=G[j])
            # print(result, 'r', G[j])

         j range(g_length) range g_length result = self.insertion_sort(array=array, array_length=array_length, g=G[j]) result self.insertion_sort(array=array, array_length=array_length, g=G[j]) self.insertion_sort self insertion_sort array=array array array array_length=array_length array_length array_length g=G[j] g G[j] G j print(g_length) print g_length print(*G) print *G G print(self.count) print self.count self count print(*result, sep='\n') print *result result sep='\n' sep '\n' self self def insertion_sort(self, array, array_length, g):
        # write your code here

        for i in range(g, array_length):
            v = array[i]
            j = i - g
            while j >= 0 and array[j] > v:
                array[j + g] = array[j]
                j -= g
                self.count += 1
            array[j + g] = v

        # print(" ".join(map(str, array)))
        return array insertion_sort for i in range(g, array_length):
            v = array[i]
            j = i - g
            while j >= 0 and array[j] > v:
                array[j + g] = array[j]
                j -= g
                self.count += 1
            array[j + g] = v

        # print(" ".join(map(str, array)))
         i range(g, array_length) range g array_length v = array[i] v array[i] array i j = i - g j i - g i g while j >= 0 and array[j] > v:
                array[j + g] = array[j]
                j -= g
                self.count += 1
             j >= 0 and array[j] > v j >= 0 j 0 array[j] > v array[j] array j v array[j + g] = array[j] array[j + g] array j + g j g array[j] array j j -= g j g self.count += 1 self.count self count 1 array[j + g] = v array[j + g] array j + g j g v return array array self self array array array_length array_length g g if __name__ == '__main__':
    solution = Solution()
    solution.shell_sort() __name__ == '__main__' __name__ '__main__' solution = Solution() solution Solution() Solution solution.shell_sort() solution.shell_sort solution shell_sort class Solution:
    def __init__(self):
        self.count = 0

    def shell_sort(self):
        _input = sys.stdin.readlines()
        array_length = int(_input[0])
        array = list(map(int, _input[1:]))

        G = [1]
        while True:
            g = G[0] * 3 + 1
            if g > array_length:
                break
            G.insert(0, g)

        g_length = len(G)
        result = []
        for j in range(g_length):
            result = self.insertion_sort(array=array, array_length=array_length, g=G[j])
            # print(result, 'r', G[j])

        print(g_length)
        print(*G)
        print(self.count)
        print(*result, sep='\n')

    def insertion_sort(self, array, array_length, g):
        # write your code here

        for i in range(g, array_length):
            v = array[i]
            j = i - g
            while j >= 0 and array[j] > v:
                array[j + g] = array[j]
                j -= g
                self.count += 1
            array[j + g] = v

        # print(" ".join(map(str, array)))
        return array class Solution:
    def __init__(self):
        self.count = 0

    def shell_sort(self):
        _input = sys.stdin.readlines()
        array_length = int(_input[0])
        array = list(map(int, _input[1:]))

        G = [1]
        while True:
            g = G[0] * 3 + 1
            if g > array_length:
                break
            G.insert(0, g)

        g_length = len(G)
        result = []
        for j in range(g_length):
            result = self.insertion_sort(array=array, array_length=array_length, g=G[j])
            # print(result, 'r', G[j])

        print(g_length)
        print(*G)
        print(self.count)
        print(*result, sep='\n')

    def insertion_sort(self, array, array_length, g):
        # write your code here

        for i in range(g, array_length):
            v = array[i]
            j = i - g
            while j >= 0 and array[j] > v:
                array[j + g] = array[j]
                j -= g
                self.count += 1
            array[j + g] = v

        # print(" ".join(map(str, array)))
        return array Solution solution = Solution() Solution() solution
#!/usr/bin/env python
# encoding: utf-8

import sys


class Solution:
    def __init__(self):
        self.count = 0

    def shell_sort(self):
        _input = sys.stdin.readlines()
        array_length = int(_input[0])
        array = list(map(int, _input[1:]))

        G = [1]
        while True:
            g = G[0] * 3 + 1
            if g > array_length:
                break
            G.insert(0, g)

        g_length = len(G)
        result = []
        for j in range(g_length):
            result = self.insertion_sort(array=array, array_length=array_length, g=G[j])
            # print(result, 'r', G[j])

        print(g_length)
        print(*G)
        print(self.count)
        print(*result, sep='\n')

    def insertion_sort(self, array, array_length, g):
        # write your code here

        for i in range(g, array_length):
            v = array[i]
            j = i - g
            while j >= 0 and array[j] > v:
                array[j + g] = array[j]
                j -= g
                self.count += 1
            array[j + g] = v

        # print(" ".join(map(str, array)))
        return array


if __name__ == '__main__':
    solution = Solution()
    solution.shell_sort()