#D13212. Shell Sort
Shell Sort
Shell Sort
Shell Sort
Shell Sort is a generalization of Insertion Sort to arrange a list of elements .
1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i])
A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every -th elements. Beginning with large values of , it repeats the insertion sort with smaller .
Your task is to complete the above program by filling ?. Write a program which reads an integer and a sequence , and prints , in the pseudo code and the sequence in ascending order. The output of your program must meet the following requirements:
- cnt does not exceed
Constraints
Input
In the first line, an integer is given. In the following lines, are given for each line.
Output
In the first line, print an integer . In the second line, print integers separated by single space character in a line. In the third line, print cnt in a line. In the following lines, print respectively.
This problem has multiple solutions and the judge will be performed by a special validator.
Examples
Input
5 5 1 4 3 2
Output
2 4 1 3 1 2 3 4 5
Input
3 3 2 1
Output
1 1 3 1 2 3
inputFormat
outputFormat
output of your program must meet the following requirements:
- cnt does not exceed
Constraints
Input
In the first line, an integer is given. In the following lines, are given for each line.
Output
In the first line, print an integer . In the second line, print integers separated by single space character in a line. In the third line, print cnt in a line. In the following lines, print respectively.
This problem has multiple solutions and the judge will be performed by a special validator.
Examples
Input
5 5 1 4 3 2
Output
2 4 1 3 1 2 3 4 5
Input
3 3 2 1
Output
1 1 3 1 2 3
样例
5
5
1
4
3
2
2
4 1
3
1
2
3
4
5
</p>