def insetion_sort(A, n, g, cnt) :
        cnt = 0
        for i in range(g, n) :
            v = A[i]
            j = i - g
            while j >= 0 and A[j] > v :
                A[j+g] = A[j]
                j = j -g
                cnt += 1
            A[j+g] = v
        return cnt


def shell_sort(A, n) :
        cnt = 0
        count = 0
        G_sub = []
        h = 1
        while h <= n :
                G_sub.append(h)
                h = 3 * h + 1
        m = len(G_sub)
        G = G_sub[::-1]

        for i in range(m) :
                count += insetion_sort(A, n, G[i], cnt)

        print(m)
        if len(G) == 1 :
                print(G[0])
        else :
                print(" ".join(map(str, G)))
        print(count)


def main() :
        n = int(input())
        nums = []
        for i in range(n) :
                nums.append(int(input()))

        shell_sort(nums, n)
        for i in range(n) :
                print(nums[i])

if __name__ == '__main__' :
        main() def insetion_sort(A, n, g, cnt) :
        cnt = 0
        for i in range(g, n) :
            v = A[i]
            j = i - g
            while j >= 0 and A[j] > v :
                A[j+g] = A[j]
                j = j -g
                cnt += 1
            A[j+g] = v
        return cnt insetion_sort cnt = 0 cnt 0 for i in range(g, n) :
            v = A[i]
            j = i - g
            while j >= 0 and A[j] > v :
                A[j+g] = A[j]
                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 j >= 0 and A[j] > v :
                A[j+g] = A[j]
                j = j -g
                cnt += 1
             j >= 0 and A[j] > v j >= 0 j 0 A[j] > v A[j] A j v A[j+g] = A[j] A[j+g] A j+g j g A[j] A j j = j -g j j -g j g cnt += 1 cnt 1 A[j+g] = v A[j+g] A j+g j g v return cnt cnt A A n n g g cnt cnt def shell_sort(A, n) :
        cnt = 0
        count = 0
        G_sub = []
        h = 1
        while h <= n :
                G_sub.append(h)
                h = 3 * h + 1
        m = len(G_sub)
        G = G_sub[::-1]

        for i in range(m) :
                count += insetion_sort(A, n, G[i], cnt)

        print(m)
        if len(G) == 1 :
                print(G[0])
        else :
                print(" ".join(map(str, G)))
        print(count) shell_sort cnt = 0 cnt 0 count = 0 count 0 G_sub = [] G_sub [] h = 1 h 1 while h <= n :
                G_sub.append(h)
                h = 3 * h + 1
         h <= n h n G_sub.append(h) G_sub.append G_sub append h h = 3 * h + 1 h 3 * h + 1 3 * h 3 h 1 m = len(G_sub) m len(G_sub) len G_sub G = G_sub[::-1] G G_sub[::-1] G_sub ::-1 -1 for i in range(m) :
                count += insetion_sort(A, n, G[i], cnt)

         i range(m) range m count += insetion_sort(A, n, G[i], cnt) count insetion_sort(A, n, G[i], cnt) insetion_sort A n G[i] G i cnt print(m) print m if len(G) == 1 :
                print(G[0])
        else :
                print(" ".join(map(str, G)))
         len(G) == 1 len(G) len G 1 print(G[0]) print G[0] G 0 print(" ".join(map(str, G))) print " ".join(map(str, G)) " ".join " " join map(str, G) map str G print(count) print count A A n n def main() :
        n = int(input())
        nums = []
        for i in range(n) :
                nums.append(int(input()))

        shell_sort(nums, n)
        for i in range(n) :
                print(nums[i]) main n = int(input()) n int(input()) int input() input nums = [] nums [] for i in range(n) :
                nums.append(int(input()))

         i range(n) range n nums.append(int(input())) nums.append nums append int(input()) int input() input shell_sort(nums, n) shell_sort nums n for i in range(n) :
                print(nums[i]) i range(n) range n print(nums[i]) print nums[i] nums i if __name__ == '__main__' :
        main() __name__ == '__main__' __name__ '__main__' main() main def main() :
        n = int(input())
        nums = []
        for i in range(n) :
                nums.append(int(input()))

        shell_sort(nums, n)
        for i in range(n) :
                print(nums[i]) def main() :
        n = int(input())
        nums = []
        for i in range(n) :
                nums.append(int(input()))

        shell_sort(nums, n)
        for i in range(n) :
                print(nums[i]) main def shell_sort(A, n) :
        cnt = 0
        count = 0
        G_sub = []
        h = 1
        while h <= n :
                G_sub.append(h)
                h = 3 * h + 1
        m = len(G_sub)
        G = G_sub[::-1]

        for i in range(m) :
                count += insetion_sort(A, n, G[i], cnt)

        print(m)
        if len(G) == 1 :
                print(G[0])
        else :
                print(" ".join(map(str, G)))
        print(count) def shell_sort(A, n) :
        cnt = 0
        count = 0
        G_sub = []
        h = 1
        while h <= n :
                G_sub.append(h)
                h = 3 * h + 1
        m = len(G_sub)
        G = G_sub[::-1]

        for i in range(m) :
                count += insetion_sort(A, n, G[i], cnt)

        print(m)
        if len(G) == 1 :
                print(G[0])
        else :
                print(" ".join(map(str, G)))
        print(count) shell_sort def insetion_sort(A, n, g, cnt) :
        cnt = 0
        for i in range(g, n) :
            v = A[i]
            j = i - g
            while j >= 0 and A[j] > v :
                A[j+g] = A[j]
                j = j -g
                cnt += 1
            A[j+g] = v
        return cnt def insetion_sort(A, n, g, cnt) :
        cnt = 0
        for i in range(g, n) :
            v = A[i]
            j = i - g
            while j >= 0 and A[j] > v :
                A[j+g] = A[j]
                j = j -g
                cnt += 1
            A[j+g] = v
        return cnt insetion_sort
def insetion_sort(A, n, g, cnt) :
        cnt = 0
        for i in range(g, n) :
            v = A[i]
            j = i - g
            while j >= 0 and A[j] > v :
                A[j+g] = A[j]
                j = j -g
                cnt += 1
            A[j+g] = v
        return cnt


def shell_sort(A, n) :
        cnt = 0
        count = 0
        G_sub = []
        h = 1
        while h <= n :
                G_sub.append(h)
                h = 3 * h + 1
        m = len(G_sub)
        G = G_sub[::-1]

        for i in range(m) :
                count += insetion_sort(A, n, G[i], cnt)

        print(m)
        if len(G) == 1 :
                print(G[0])
        else :
                print(" ".join(map(str, G)))
        print(count)


def main() :
        n = int(input())
        nums = []
        for i in range(n) :
                nums.append(int(input()))

        shell_sort(nums, n)
        for i in range(n) :
                print(nums[i])

if __name__ == '__main__' :
        main()