import sys

STEP = 2

def insert_sort(array, step, cnt):
    for i in range(step, len(array)):
        v = array[i]
        j = i - step
        while (j >= 0) and (array[j] > v):
            array[j + step] = array[j]
            j = j - step
            cnt += 1
        array[j + step] = v
    return cnt

def shell_sort(array):
    cnt = 0
    v = int(len(array)/STEP)
    step_list = []
    while v > 0:
        step_list.append(v)
        v = int(v/STEP)
    if len(step_list) == 0:
        step_list.append(1)
    for step in step_list:
        cnt = insert_sort(array, step, cnt)
    return (cnt, step_list)

def list_to_string(array):
    s = ""
    for n in array:
        s += str(n) + " "
    return s.strip()

def main():
    num = int(sys.stdin.readline().strip())
    array = [int(sys.stdin.readline().strip()) for i in range(0, num)]
    c = shell_sort(array)
    print str(len(c[1]))
    print list_to_string(c[1])
    print str(c[0])
    for n in array:
        print str(n)

if __name__ == "__main__":
    main() import sys sys STEP = 2 STEP 2 def insert_sort(array, step, cnt):
    for i in range(step, len(array)):
        v = array[i]
        j = i - step
        while (j >= 0) and (array[j] > v):
            array[j + step] = array[j]
            j = j - step
            cnt += 1
        array[j + step] = v
    return cnt insert_sort for i in range(step, len(array)):
        v = array[i]
        j = i - step
        while (j >= 0) and (array[j] > v):
            array[j + step] = array[j]
            j = j - step
            cnt += 1
        array[j + step] = v
     i range(step, len(array)) range step len(array) len array v = array[i] v array[i] array i j = i - step j i - step i step while (j >= 0) and (array[j] > v):
            array[j + step] = array[j]
            j = j - step
            cnt += 1
         (j >= 0) and (array[j] > v) j >= 0 j 0 array[j] > v array[j] array j v array[j + step] = array[j] array[j + step] array j + step j step array[j] array j j = j - step j j - step j step cnt += 1 cnt 1 array[j + step] = v array[j + step] array j + step j step v return cnt cnt array array step step cnt cnt def shell_sort(array):
    cnt = 0
    v = int(len(array)/STEP)
    step_list = []
    while v > 0:
        step_list.append(v)
        v = int(v/STEP)
    if len(step_list) == 0:
        step_list.append(1)
    for step in step_list:
        cnt = insert_sort(array, step, cnt)
    return (cnt, step_list) shell_sort cnt = 0 cnt 0 v = int(len(array)/STEP) v int(len(array)/STEP) int len(array)/STEP len(array) len array STEP step_list = [] step_list [] while v > 0:
        step_list.append(v)
        v = int(v/STEP)
     v > 0 v 0 step_list.append(v) step_list.append step_list append v v = int(v/STEP) v int(v/STEP) int v/STEP v STEP if len(step_list) == 0:
        step_list.append(1)
     len(step_list) == 0 len(step_list) len step_list 0 step_list.append(1) step_list.append step_list append 1 for step in step_list:
        cnt = insert_sort(array, step, cnt)
     step step_list cnt = insert_sort(array, step, cnt) cnt insert_sort(array, step, cnt) insert_sort array step cnt return (cnt, step_list) (cnt, step_list) cnt step_list array array def list_to_string(array):
    s = ""
    for n in array:
        s += str(n) + " "
    return s.strip() list_to_string s = "" s "" for n in array:
        s += str(n) + " "
     n array s += str(n) + " " s str(n) + " " str(n) str n " " return s.strip() s.strip() s.strip s strip array array def main():
    num = int(sys.stdin.readline().strip())
    array = [int(sys.stdin.readline().strip()) for i in range(0, num)]
    c = shell_sort(array)
    print str(len(c[1]))
    print list_to_string(c[1])
    print str(c[0])
    for n in array:
        print str(n) main num = int(sys.stdin.readline().strip()) num int(sys.stdin.readline().strip()) int sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip int(sys.stdin.readline().strip()) for i in range(0, num) for i in range(0, num) i range(0, num) range 0 num for i in range(0, num) int(sys.stdin.readline().strip()) int sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip array = [int(sys.stdin.readline().strip()) for i in range(0, num)] array [int(sys.stdin.readline().strip()) for i in range(0, num)] c = shell_sort(array) c shell_sort(array) shell_sort array print str(len(c[1])) str len(c[1]) len c[1] c 1 print list_to_string(c[1]) list_to_string c[1] c 1 print str(c[0]) str c[0] c 0 for n in array:
        print str(n) n array print str(n) str n if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main STEP = 2 2 STEP def insert_sort(array, step, cnt):
    for i in range(step, len(array)):
        v = array[i]
        j = i - step
        while (j >= 0) and (array[j] > v):
            array[j + step] = array[j]
            j = j - step
            cnt += 1
        array[j + step] = v
    return cnt def insert_sort(array, step, cnt):
    for i in range(step, len(array)):
        v = array[i]
        j = i - step
        while (j >= 0) and (array[j] > v):
            array[j + step] = array[j]
            j = j - step
            cnt += 1
        array[j + step] = v
    return cnt insert_sort def list_to_string(array):
    s = ""
    for n in array:
        s += str(n) + " "
    return s.strip() def list_to_string(array):
    s = ""
    for n in array:
        s += str(n) + " "
    return s.strip() list_to_string def main():
    num = int(sys.stdin.readline().strip())
    array = [int(sys.stdin.readline().strip()) for i in range(0, num)]
    c = shell_sort(array)
    print str(len(c[1]))
    print list_to_string(c[1])
    print str(c[0])
    for n in array:
        print str(n) def main():
    num = int(sys.stdin.readline().strip())
    array = [int(sys.stdin.readline().strip()) for i in range(0, num)]
    c = shell_sort(array)
    print str(len(c[1]))
    print list_to_string(c[1])
    print str(c[0])
    for n in array:
        print str(n) main def shell_sort(array):
    cnt = 0
    v = int(len(array)/STEP)
    step_list = []
    while v > 0:
        step_list.append(v)
        v = int(v/STEP)
    if len(step_list) == 0:
        step_list.append(1)
    for step in step_list:
        cnt = insert_sort(array, step, cnt)
    return (cnt, step_list) def shell_sort(array):
    cnt = 0
    v = int(len(array)/STEP)
    step_list = []
    while v > 0:
        step_list.append(v)
        v = int(v/STEP)
    if len(step_list) == 0:
        step_list.append(1)
    for step in step_list:
        cnt = insert_sort(array, step, cnt)
    return (cnt, step_list) shell_sort
import sys

STEP = 2

def insert_sort(array, step, cnt):
    for i in range(step, len(array)):
        v = array[i]
        j = i - step
        while (j >= 0) and (array[j] > v):
            array[j + step] = array[j]
            j = j - step
            cnt += 1
        array[j + step] = v
    return cnt

def shell_sort(array):
    cnt = 0
    v = int(len(array)/STEP)
    step_list = []
    while v > 0:
        step_list.append(v)
        v = int(v/STEP)
    if len(step_list) == 0:
        step_list.append(1)
    for step in step_list:
        cnt = insert_sort(array, step, cnt)
    return (cnt, step_list)

def list_to_string(array):
    s = ""
    for n in array:
        s += str(n) + " "
    return s.strip()

def main():
    num = int(sys.stdin.readline().strip())
    array = [int(sys.stdin.readline().strip()) for i in range(0, num)]
    c = shell_sort(array)
    print str(len(c[1]))
    print list_to_string(c[1])
    print str(c[0])
    for n in array:
        print str(n)

if __name__ == "__main__":
    main()