Buggy python submission (verdict: Runtime Error):
def insertionSort(A, n, g):
    global cnt 

    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

def shellSort(A, n):
    global cnt
    cnt = 0
    g = 2
    m = n // g
    print(m)  # 1行目
    G = list(range(g*m,g*(m-1),-g))
    G.append(1)
    G = G[-1*(m):]
    print(" ".join(list(map(str,G))))  # 2行目
    for i in range(0,m):
        insertionSort(A, n, G[i])
    print(cnt)  # 3行目
    for i in range(0,len(A)):
        print(A[i]) # 4行目以降

cnt = 0
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
#print("-"*10)
shellSort(A,n)


Fixed submission:
def insertionSort(A, n, g):
    global cnt 

    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

def shellSort(A, n):
    global cnt
    cnt = 0
    g = 1
    G = [1]
    m = 1
    for i in range(1,101):
        tmp = G[i-1]+(3)**i
        if tmp <= n:
            m = i+1
            G.append(tmp)
            g += 1
        else:
            break
    G.reverse() 
    print(m)  # 1行目
    print(" ".join(list(map(str,G))))  # 2行目

    for i in range(0,m):
        insertionSort(A, n, G[i])
    print(cnt)  # 3行目
    for i in range(0,len(A)):
        print(A[i]) # 4行目以降

cnt = 0
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
shellSort(A,n)

Buggy python submission (verdict: Runtime Error):
def insertionSort(A, n, g):
    global cnt 

    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

def shellSort(A, n):
    global cnt
    cnt = 0
    #g = 3
    #g = n // 2 * 2
    g = 2
    #m = max(n // g,1)
    #m = min(m, 100)
    #print(m)  # 1行目
    #G = list(range(g*m,g,-g))
    G = [1]
    for i in range(1,101):
        # gの2乗分ずつGのリスト値を変えていく
        # mは結果のリストから取得 
        #print("g**i:{} ,n:{}".format(g**i, n))
        if g**i <= n:
            m = i+1
            G.append(g**i)
            g += 1
        else:
            break
    G.reverse() 
    print(m)  # 1行目
    print(" ".join(list(map(str,G))))  # 2行目
    for i in range(0,m):
        insertionSort(A, n, G[i])
    print(cnt)  # 3行目
    for i in range(0,len(A)):
        print(A[i]) # 4行目以降

cnt = 0
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))

shellSort(A,n)


Fixed submission:
def insertionSort(A, n, g):
    global cnt 

    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

def shellSort(A, n):
    global cnt
    cnt = 0
    g = 1
    G = [1]
    m = 1
    for i in range(1,101):
        tmp = G[i-1]+(3)**i
        if tmp <= n:
            m = i+1
            G.append(tmp)
            g += 1
        else:
            break
    G.reverse() 
    print(m)  # 1行目
    print(" ".join(list(map(str,G))))  # 2行目

    for i in range(0,m):
        insertionSort(A, n, G[i])
    print(cnt)  # 3行目
    for i in range(0,len(A)):
        print(A[i]) # 4行目以降

cnt = 0
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
shellSort(A,n)

Buggy python submission (verdict: Runtime Error):
def insertionSort(A, n, g):
    global cnt 

    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

def shellSort(A, n):
    global cnt
    cnt = 0
    #g = 3
    #g = n // 2 * 2
    g = 2
    #m = max(n // g,1)
    #m = min(m, 100)
    #print(m)  # 1行目
    #G = list(range(g*m,g,-g))
    G = [1]
    m = 1
    for i in range(1,101):
        # gの2乗分ずつGのリスト値を変えていく
        # mは結果のリストから取得 
        #print("g**i:{} ,n:{}".format(g**i, n))
        if g**i <= n:
            m = i+1
            G.append(g**i)
            g += 1
        else:
            break
    G.reverse() 
    print(m)  # 1行目
    print(" ".join(list(map(str,G))))  # 2行目
    for i in range(0,m):
        insertionSort(A, n, G[i])
    print(cnt)  # 3行目
    for i in range(0,len(A)):
        print(A[i]) # 4行目以降

cnt = 0
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))

shellSort(A,n)


Fixed submission:
def insertionSort(A, n, g):
    global cnt 

    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

def shellSort(A, n):
    global cnt
    cnt = 0
    g = 1
    G = [1]
    m = 1
    for i in range(1,101):
        tmp = G[i-1]+(3)**i
        if tmp <= n:
            m = i+1
            G.append(tmp)
            g += 1
        else:
            break
    G.reverse() 
    print(m)  # 1行目
    print(" ".join(list(map(str,G))))  # 2行目

    for i in range(0,m):
        insertionSort(A, n, G[i])
    print(cnt)  # 3行目
    for i in range(0,len(A)):
        print(A[i]) # 4行目以降

cnt = 0
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
shellSort(A,n)

Buggy python submission (verdict: Runtime Error):
def insertionSort(A, n, g):
    global cnt 

    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

def shellSort(A, n):
    global cnt
    cnt = 0
    #g = 3
    #g = n // 2 * 2
    g = 2
    #m = max(n // g,1)
    #m = min(m, 100)
    #print(m)  # 1行目
    #G = list(range(g*m,g,-g))
    G = [1]
    m = 1
    for i in range(1,101):
        # gの2乗分ずつGのリスト値を変えていく
        # mは結果のリストから取得 
        #print("g**i:{} ,n:{}".format(g**i, n))
        if g**i <= n:
            m = i+1
            G.append(g**i)
            g += 1
        else:
            break
    G.reverse() 
    print(m)  # 1行目
    print(" ".join(list(map(str,G))))  # 2行目
    for i in range(0,m):
        insertionSort(A, n, G[i])
    print(cnt)  # 3行目
    for i in range(0,len(A)):
        print(A[i]) # 4行目以降

cnt = 0
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))

shellSort(A,n)


Fixed submission:
def insertionSort(A, n, g):
    global cnt 

    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

def shellSort(A, n):
    global cnt
    cnt = 0
    g = 1
    G = [1]
    m = 1
    for i in range(1,101):
        tmp = G[i-1]+(3)**i
        if tmp <= n:
            m = i+1
            G.append(tmp)
            g += 1
        else:
            break
    G.reverse() 
    print(m)  # 1行目
    print(" ".join(list(map(str,G))))  # 2行目

    for i in range(0,m):
        insertionSort(A, n, G[i])
    print(cnt)  # 3行目
    for i in range(0,len(A)):
        print(A[i]) # 4行目以降

cnt = 0
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
shellSort(A,n)

Buggy python submission (verdict: Runtime Error):
def insertionSort(A, n, g):
    global cnt 

    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

def shellSort(A, n):
    global cnt
    cnt = 0
    g = 4
    G = [1]
    m = 1
    for i in range(1,101):
        if g**i <= n:
            m = i+1
            G.append(g**i)
            g += 1
        else:
            break
    G.reverse() 
    print(m)  # 1行目
    print(" ".join(list(map(str,G))))  # 2行目
    for i in range(0,m):
        insertionSort(A, n, G[i])
    print(cnt)  # 3行目
    for i in range(0,len(A)):
        print(A[i]) # 4行目以降

cnt = 0
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))

shellSort(A,n)


Fixed submission:
def insertionSort(A, n, g):
    global cnt 

    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

def shellSort(A, n):
    global cnt
    cnt = 0
    g = 1
    G = [1]
    m = 1
    for i in range(1,101):
        tmp = G[i-1]+(3)**i
        if tmp <= n:
            m = i+1
            G.append(tmp)
            g += 1
        else:
            break
    G.reverse() 
    print(m)  # 1行目
    print(" ".join(list(map(str,G))))  # 2行目

    for i in range(0,m):
        insertionSort(A, n, G[i])
    print(cnt)  # 3行目
    for i in range(0,len(A)):
        print(A[i]) # 4行目以降

cnt = 0
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
shellSort(A,n)

Buggy python submission (verdict: Runtime Error):
def insertionSort(A, n, g):
    global cnt 

    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

def shellSort(A, n):
    global cnt
    cnt = 0
    g = 1
    G = [1]
    m = 1
    for i in range(1,101):
        tmp = G[-1]**2+g**2
        if tmp <= n:
            m = i+1
            G.append(tmp)
            g += 1
        else:
            break
    G.reverse() 
    print(m)  # 1行目
    print(" ".join(list(map(str,G))))  # 2行目
    for i in range(0,m):
        insertionSort(A, n, G[i])
    print(cnt)  # 3行目
    for i in range(0,len(A)):
        print(A[i]) # 4行目以降

cnt = 0
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
shellSort(A,n)


Fixed submission:
def insertionSort(A, n, g):
    global cnt 

    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

def shellSort(A, n):
    global cnt
    cnt = 0
    g = 1
    G = [1]
    m = 1
    for i in range(1,101):
        tmp = G[i-1]+(3)**i
        if tmp <= n:
            m = i+1
            G.append(tmp)
            g += 1
        else:
            break
    G.reverse() 
    print(m)  # 1行目
    print(" ".join(list(map(str,G))))  # 2行目

    for i in range(0,m):
        insertionSort(A, n, G[i])
    print(cnt)  # 3行目
    for i in range(0,len(A)):
        print(A[i]) # 4行目以降

cnt = 0
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
shellSort(A,n)

Buggy python submission (verdict: Runtime Error):
def insertionSort(A, n, g):
    global cnt 

    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

def shellSort(A, n):
    global cnt
    cnt = 0
    g = 1
    G = [0]
    m = 1
    for i in range(1,101):
        tmp = G[-1]**2+(g+1)**2
        if tmp <= n:
            m = i+1
            G.append(tmp)
            g += 1
        else:
            break
    G[0] = 1
    G.reverse() 
    print(m)  # 1行目
    print(" ".join(list(map(str,G))))  # 2行目
    for i in range(0,m):
        insertionSort(A, n, G[i])
    print(cnt)  # 3行目
    for i in range(0,len(A)):
        print(A[i]) # 4行目以降

cnt = 0
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))

shellSort(A,n)


Fixed submission:
def insertionSort(A, n, g):
    global cnt 

    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

def shellSort(A, n):
    global cnt
    cnt = 0
    g = 1
    G = [1]
    m = 1
    for i in range(1,101):
        tmp = G[i-1]+(3)**i
        if tmp <= n:
            m = i+1
            G.append(tmp)
            g += 1
        else:
            break
    G.reverse() 
    print(m)  # 1行目
    print(" ".join(list(map(str,G))))  # 2行目

    for i in range(0,m):
        insertionSort(A, n, G[i])
    print(cnt)  # 3行目
    for i in range(0,len(A)):
        print(A[i]) # 4行目以降

cnt = 0
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
shellSort(A,n)

Buggy python submission (verdict: Runtime Error):
def insertionSort(A, n, g):
    global cnt 

    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

def shellSort(A, n):
    global cnt
    cnt = 0
    g = 1
    G = [1]
    m = 1
    for i in range(1,101):
        tmp = G[-1]**2+(3)**i
        if tmp <= n:
            m = i+1
            G.append(tmp)
            g += 1
        else:
            break
    #G[0] = 1
    G.reverse() 
    print(m)  # 1行目
    print(" ".join(list(map(str,G))))  # 2行目
    for i in range(0,m):
        insertionSort(A, n, G[i])
    print(cnt)  # 3行目
    for i in range(0,len(A)):
        print(A[i]) # 4行目以降

cnt = 0
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))

shellSort(A,n)


Fixed submission:
def insertionSort(A, n, g):
    global cnt 

    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

def shellSort(A, n):
    global cnt
    cnt = 0
    g = 1
    G = [1]
    m = 1
    for i in range(1,101):
        tmp = G[i-1]+(3)**i
        if tmp <= n:
            m = i+1
            G.append(tmp)
            g += 1
        else:
            break
    G.reverse() 
    print(m)  # 1行目
    print(" ".join(list(map(str,G))))  # 2行目

    for i in range(0,m):
        insertionSort(A, n, G[i])
    print(cnt)  # 3行目
    for i in range(0,len(A)):
        print(A[i]) # 4行目以降

cnt = 0
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
shellSort(A,n)