def insertionSort(insert_list, num, g): 
    cnt = 0 
    for i in range(g, num):
        temp = insert_list[i]
        j = i - g 
        while (j >= 0 and insert_list[j] > temp):
            insert_list[j+g] = insert_list[j]
            j -= g
            cnt += 1
        insert_list[j+g] = temp
    return insert_list, cnt 

def shellSort(shell_list, num):
    cnt = 0 
    G = [1] 
    G_num = 1 
    for i in range(num):
        G_num = G_num*3 + 1 
        if G_num > num:
            break
        else:
            G.append(G_num)
    G.reverse()
    m = len(G)

    for i in range(m):
        shell_list, cnt_num = insertionSort(shell_list, num, G[i])
        cnt += cnt_num
    return m, G, cnt, shell_list    

if __name__ == "__main__":
    num = int(raw_input())
    num_list = [int(raw_input()) for i in range(num)]

    m, G, cnt, shell_list = shellSort(num_list, num)

    print m
    G = map(str, G)
    print " ".join(G)
    print cnt 
    for i in shell_list:
        print i def insertionSort(insert_list, num, g): 
    cnt = 0 
    for i in range(g, num):
        temp = insert_list[i]
        j = i - g 
        while (j >= 0 and insert_list[j] > temp):
            insert_list[j+g] = insert_list[j]
            j -= g
            cnt += 1
        insert_list[j+g] = temp
    return insert_list, cnt  insertionSort cnt = 0 cnt 0 for i in range(g, num):
        temp = insert_list[i]
        j = i - g 
        while (j >= 0 and insert_list[j] > temp):
            insert_list[j+g] = insert_list[j]
            j -= g
            cnt += 1
        insert_list[j+g] = temp
     i range(g, num) range g num temp = insert_list[i] temp insert_list[i] insert_list i j = i - g j i - g i g while (j >= 0 and insert_list[j] > temp):
            insert_list[j+g] = insert_list[j]
            j -= g
            cnt += 1
         j >= 0 and insert_list[j] > temp j >= 0 j 0 insert_list[j] > temp insert_list[j] insert_list j temp insert_list[j+g] = insert_list[j] insert_list[j+g] insert_list j+g j g insert_list[j] insert_list j j -= g j g cnt += 1 cnt 1 insert_list[j+g] = temp insert_list[j+g] insert_list j+g j g temp return insert_list, cnt return insert_list, cnt insert_list cnt insert_list insert_list num num g g def shellSort(shell_list, num):
    cnt = 0 
    G = [1] 
    G_num = 1 
    for i in range(num):
        G_num = G_num*3 + 1 
        if G_num > num:
            break
        else:
            G.append(G_num)
    G.reverse()
    m = len(G)

    for i in range(m):
        shell_list, cnt_num = insertionSort(shell_list, num, G[i])
        cnt += cnt_num
    return m, G, cnt, shell_list     shellSort cnt = 0 cnt 0 G = [1] G [1] 1 G_num = 1 G_num 1 for i in range(num):
        G_num = G_num*3 + 1 
        if G_num > num:
            break
        else:
            G.append(G_num)
     i range(num) range num G_num = G_num*3 + 1 G_num G_num*3 + 1 G_num*3 G_num 3 1 if G_num > num:
            break
        else:
            G.append(G_num)
     G_num > num G_num num break G.append(G_num) G.append G append G_num G.reverse() G.reverse G reverse m = len(G) m len(G) len G for i in range(m):
        shell_list, cnt_num = insertionSort(shell_list, num, G[i])
        cnt += cnt_num
     i range(m) range m shell_list, cnt_num = insertionSort(shell_list, num, G[i]) shell_list insertionSort(shell_list, num, G[i]) insertionSort shell_list num G[i] G i cnt_num cnt += cnt_num cnt cnt_num return m, G, cnt, shell_list return m, G, cnt, shell_list m G cnt shell_list shell_list shell_list num num if __name__ == "__main__":
    num = int(raw_input())
    num_list = [int(raw_input()) for i in range(num)]

    m, G, cnt, shell_list = shellSort(num_list, num)

    print m
    G = map(str, G)
    print " ".join(G)
    print cnt 
    for i in shell_list:
        print i __name__ == "__main__" __name__ "__main__" num = int(raw_input()) num int(raw_input()) int raw_input() raw_input int(raw_input()) for i in range(num) for i in range(num) i range(num) range num for i in range(num) int(raw_input()) int raw_input() raw_input num_list = [int(raw_input()) for i in range(num)] num_list [int(raw_input()) for i in range(num)] m, G, cnt, shell_list = shellSort(num_list, num) m shellSort(num_list, num) shellSort num_list num G cnt shell_list print G = map(str, G) G map(str, G) map str G print " ".join(G) " ".join " " join G print for i in shell_list:
        print i i shell_list print m, G, cnt, shell_list = shellSort(num_list, num) shellSort(num_list, num) m G = map(str, G) map(str, G) G def shellSort(shell_list, num):
    cnt = 0 
    G = [1] 
    G_num = 1 
    for i in range(num):
        G_num = G_num*3 + 1 
        if G_num > num:
            break
        else:
            G.append(G_num)
    G.reverse()
    m = len(G)

    for i in range(m):
        shell_list, cnt_num = insertionSort(shell_list, num, G[i])
        cnt += cnt_num
    return m, G, cnt, shell_list     def shellSort(shell_list, num):
    cnt = 0 
    G = [1] 
    G_num = 1 
    for i in range(num):
        G_num = G_num*3 + 1 
        if G_num > num:
            break
        else:
            G.append(G_num)
    G.reverse()
    m = len(G)

    for i in range(m):
        shell_list, cnt_num = insertionSort(shell_list, num, G[i])
        cnt += cnt_num
    return m, G, cnt, shell_list     shellSort num_list = [int(raw_input()) for i in range(num)] [int(raw_input()) for i in range(num)] num_list G, cnt, shell_list = shellSort(num_list, num) shellSort(num_list, num) G cnt, shell_list = shellSort(num_list, num) shellSort(num_list, num) cnt num = int(raw_input()) int(raw_input()) num def insertionSort(insert_list, num, g): 
    cnt = 0 
    for i in range(g, num):
        temp = insert_list[i]
        j = i - g 
        while (j >= 0 and insert_list[j] > temp):
            insert_list[j+g] = insert_list[j]
            j -= g
            cnt += 1
        insert_list[j+g] = temp
    return insert_list, cnt  def insertionSort(insert_list, num, g): 
    cnt = 0 
    for i in range(g, num):
        temp = insert_list[i]
        j = i - g 
        while (j >= 0 and insert_list[j] > temp):
            insert_list[j+g] = insert_list[j]
            j -= g
            cnt += 1
        insert_list[j+g] = temp
    return insert_list, cnt  insertionSort shell_list = shellSort(num_list, num) shellSort(num_list, num) shell_list
def insertionSort(insert_list, num, g): 
    cnt = 0 
    for i in range(g, num):
        temp = insert_list[i]
        j = i - g 
        while (j >= 0 and insert_list[j] > temp):
            insert_list[j+g] = insert_list[j]
            j -= g
            cnt += 1
        insert_list[j+g] = temp
    return insert_list, cnt 

def shellSort(shell_list, num):
    cnt = 0 
    G = [1] 
    G_num = 1 
    for i in range(num):
        G_num = G_num*3 + 1 
        if G_num > num:
            break
        else:
            G.append(G_num)
    G.reverse()
    m = len(G)

    for i in range(m):
        shell_list, cnt_num = insertionSort(shell_list, num, G[i])
        cnt += cnt_num
    return m, G, cnt, shell_list    

if __name__ == "__main__":
    num = int(raw_input())
    num_list = [int(raw_input()) for i in range(num)]

    m, G, cnt, shell_list = shellSort(num_list, num)

    print m
    G = map(str, G)
    print " ".join(G)
    print cnt 
    for i in shell_list:
        print i