#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_D
#?????§????????????
#??????????????????????????????????????????????????\?????????????????¨??????
#???????????????????????????????????????????????????????????????????????????

cnt = 0
def insertion_sort(target_list,g):
    maxlen = len(target_list)
    global cnt
    for focus_index in range(g, maxlen):
        target = target_list[focus_index]
        
        if target < target_list[focus_index - g]:
            compare_index = focus_index - g

            while compare_index >= 0 and target_list[compare_index] > target:
                target_list[compare_index + g] = target_list[compare_index]
                compare_index = compare_index - g;
                cnt += 1
                
            target_list[compare_index + g] = target
    
    return target_list

def shell_sort(target_list):

    g = []
    g_value = 1
    while g_value <= len(target_list):
        g.append(g_value)
        g_value = 3 * g_value + 1
    g = g[::-1]
    
    print(len(g))
    print(*g)
    for i in range(0,len(g)):
        insertion_sort(target_list, g[i])

def main():
    n_list = int(input())
    target_list = [int(input()) for n in range(n_list)]
    cc = shell_sort(target_list)
    print(cnt)
    print("\n".join([str(n) for n in target_list]))
    
    
if __name__ == "__main__":
    main() cnt = 0 cnt 0 def insertion_sort(target_list,g):
    maxlen = len(target_list)
    global cnt
    for focus_index in range(g, maxlen):
        target = target_list[focus_index]
        
        if target < target_list[focus_index - g]:
            compare_index = focus_index - g

            while compare_index >= 0 and target_list[compare_index] > target:
                target_list[compare_index + g] = target_list[compare_index]
                compare_index = compare_index - g;
                cnt += 1
                
            target_list[compare_index + g] = target
    
    return target_list insertion_sort maxlen = len(target_list) maxlen len(target_list) len target_list global cnt for focus_index in range(g, maxlen):
        target = target_list[focus_index]
        
        if target < target_list[focus_index - g]:
            compare_index = focus_index - g

            while compare_index >= 0 and target_list[compare_index] > target:
                target_list[compare_index + g] = target_list[compare_index]
                compare_index = compare_index - g;
                cnt += 1
                
            target_list[compare_index + g] = target
    
     focus_index range(g, maxlen) range g maxlen target = target_list[focus_index] target target_list[focus_index] target_list focus_index if target < target_list[focus_index - g]:
            compare_index = focus_index - g

            while compare_index >= 0 and target_list[compare_index] > target:
                target_list[compare_index + g] = target_list[compare_index]
                compare_index = compare_index - g;
                cnt += 1
                
            target_list[compare_index + g] = target
    
     target < target_list[focus_index - g] target target_list[focus_index - g] target_list focus_index - g focus_index g compare_index = focus_index - g compare_index focus_index - g focus_index g while compare_index >= 0 and target_list[compare_index] > target:
                target_list[compare_index + g] = target_list[compare_index]
                compare_index = compare_index - g;
                cnt += 1
                
             compare_index >= 0 and target_list[compare_index] > target compare_index >= 0 compare_index 0 target_list[compare_index] > target target_list[compare_index] target_list compare_index target target_list[compare_index + g] = target_list[compare_index] target_list[compare_index + g] target_list compare_index + g compare_index g target_list[compare_index] target_list compare_index compare_index = compare_index - g compare_index compare_index - g compare_index g cnt += 1 cnt 1 target_list[compare_index + g] = target target_list[compare_index + g] target_list compare_index + g compare_index g target return target_list target_list target_list target_list g g def shell_sort(target_list):

    g = []
    g_value = 1
    while g_value <= len(target_list):
        g.append(g_value)
        g_value = 3 * g_value + 1
    g = g[::-1]
    
    print(len(g))
    print(*g)
    for i in range(0,len(g)):
        insertion_sort(target_list, g[i]) shell_sort g = [] g [] g_value = 1 g_value 1 while g_value <= len(target_list):
        g.append(g_value)
        g_value = 3 * g_value + 1
     g_value <= len(target_list) g_value len(target_list) len target_list g.append(g_value) g.append g append g_value g_value = 3 * g_value + 1 g_value 3 * g_value + 1 3 * g_value 3 g_value 1 g = g[::-1] g g[::-1] g ::-1 -1 print(len(g)) print len(g) len g print(*g) print *g g for i in range(0,len(g)):
        insertion_sort(target_list, g[i]) i range(0,len(g)) range 0 len(g) len g insertion_sort(target_list, g[i]) insertion_sort target_list g[i] g i target_list target_list def main():
    n_list = int(input())
    target_list = [int(input()) for n in range(n_list)]
    cc = shell_sort(target_list)
    print(cnt)
    print("\n".join([str(n) for n in target_list]))
    
     main n_list = int(input()) n_list int(input()) int input() input int(input()) for n in range(n_list) for n in range(n_list) n range(n_list) range n_list for n in range(n_list) int(input()) int input() input target_list = [int(input()) for n in range(n_list)] target_list [int(input()) for n in range(n_list)] cc = shell_sort(target_list) cc shell_sort(target_list) shell_sort target_list print(cnt) print cnt str(n) for n in target_list for n in target_list n target_list for n in target_list str(n) str n print("\n".join([str(n) for n in target_list])) print "\n".join([str(n) for n in target_list]) "\n".join "\n" join [str(n) for n in target_list] if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main cnt = 0 0 cnt def main():
    n_list = int(input())
    target_list = [int(input()) for n in range(n_list)]
    cc = shell_sort(target_list)
    print(cnt)
    print("\n".join([str(n) for n in target_list]))
    
     def main():
    n_list = int(input())
    target_list = [int(input()) for n in range(n_list)]
    cc = shell_sort(target_list)
    print(cnt)
    print("\n".join([str(n) for n in target_list]))
    
     main def shell_sort(target_list):

    g = []
    g_value = 1
    while g_value <= len(target_list):
        g.append(g_value)
        g_value = 3 * g_value + 1
    g = g[::-1]
    
    print(len(g))
    print(*g)
    for i in range(0,len(g)):
        insertion_sort(target_list, g[i]) def shell_sort(target_list):

    g = []
    g_value = 1
    while g_value <= len(target_list):
        g.append(g_value)
        g_value = 3 * g_value + 1
    g = g[::-1]
    
    print(len(g))
    print(*g)
    for i in range(0,len(g)):
        insertion_sort(target_list, g[i]) shell_sort def insertion_sort(target_list,g):
    maxlen = len(target_list)
    global cnt
    for focus_index in range(g, maxlen):
        target = target_list[focus_index]
        
        if target < target_list[focus_index - g]:
            compare_index = focus_index - g

            while compare_index >= 0 and target_list[compare_index] > target:
                target_list[compare_index + g] = target_list[compare_index]
                compare_index = compare_index - g;
                cnt += 1
                
            target_list[compare_index + g] = target
    
    return target_list def insertion_sort(target_list,g):
    maxlen = len(target_list)
    global cnt
    for focus_index in range(g, maxlen):
        target = target_list[focus_index]
        
        if target < target_list[focus_index - g]:
            compare_index = focus_index - g

            while compare_index >= 0 and target_list[compare_index] > target:
                target_list[compare_index + g] = target_list[compare_index]
                compare_index = compare_index - g;
                cnt += 1
                
            target_list[compare_index + g] = target
    
    return target_list insertion_sort
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_D
#?????§????????????
#??????????????????????????????????????????????????\?????????????????¨??????
#???????????????????????????????????????????????????????????????????????????

cnt = 0
def insertion_sort(target_list,g):
    maxlen = len(target_list)
    global cnt
    for focus_index in range(g, maxlen):
        target = target_list[focus_index]
        
        if target < target_list[focus_index - g]:
            compare_index = focus_index - g

            while compare_index >= 0 and target_list[compare_index] > target:
                target_list[compare_index + g] = target_list[compare_index]
                compare_index = compare_index - g;
                cnt += 1
                
            target_list[compare_index + g] = target
    
    return target_list

def shell_sort(target_list):

    g = []
    g_value = 1
    while g_value <= len(target_list):
        g.append(g_value)
        g_value = 3 * g_value + 1
    g = g[::-1]
    
    print(len(g))
    print(*g)
    for i in range(0,len(g)):
        insertion_sort(target_list, g[i])

def main():
    n_list = int(input())
    target_list = [int(input()) for n in range(n_list)]
    cc = shell_sort(target_list)
    print(cnt)
    print("\n".join([str(n) for n in target_list]))
    
    
if __name__ == "__main__":
    main()