Buggy python submission (verdict: Time Limit Exceeded):
import sys

sys.setrecursionlimit(200000)

N = int(input())
A = list(map(int, input().split(' ')))

def sum(a, b):
    if b == 0:
        return a[b]
    else:
        return a[b] + sum(a, b-1)
sumA = []
for i in range(N):
    sumA.append(sum(A, i))

ans = 0

for i in range(N):
    if sumA[-1] // 2 > sumA[i]:
        continue
    else:
        if i == 0:
            ans = abs(sumA[i] * 2 - sumA[-1])
            break
        else:
            ans = min(abs(sumA[i] * 2 - sumA[-1]), abs(sumA[i-1] * 2 - sumA[-1]))
            break

print(ans)

Fixed submission:
import sys
    
sys.setrecursionlimit(200000)
    
N = int(input())
A = list(map(int, input().split(' ')))
    

sumA = []
for i in range(N):
    if i == 0:
        sumA.append(A[i])
    else:
        sumA.append(sumA[-1] + A[i])
    
ans = 0
    
for i in range(N):
    if sumA[-1] // 2 > sumA[i]:
        continue
    else:
        if i == 0:
            ans = abs(sumA[i] * 2 - sumA[-1])
            break
        else:
            ans = min(abs(sumA[i] * 2 - sumA[-1]), abs(sumA[i-1] * 2 - sumA[-1]))
            break
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

sys.setrecursionlimit(200000)

N = int(input())
A = list(map(int, input().split(' ')))

def sum(a, b):
    if b == 0:
        return a[b]
    else:
        return a[b] + sum(a, b-1)
sumA = []
for i in range(N):
    sumA.append(sum(A, i))

ans = 0

for i in range(N):
    if sumA[-1] // 2 > sumA[i]:
        continue
    else:
        if i == 0:
            ans = abs(sumA[i] * 2 - sumA[-1])
            break
        else:
            ans = min(abs(sumA[i] * 2 - sumA[-1]), abs(sumA[i-1] * 2 - sumA[-1]))
            break

print(ans)

Fixed submission:
import sys
    
sys.setrecursionlimit(200000)
    
N = int(input())
A = list(map(int, input().split(' ')))
    

sumA = []
for i in range(N):
    if i == 0:
        sumA.append(A[i])
    else:
        sumA.append(sumA[-1] + A[i])
    
ans = 0
    
for i in range(N):
    if sumA[-1] // 2 > sumA[i]:
        continue
    else:
        if i == 0:
            ans = abs(sumA[i] * 2 - sumA[-1])
            break
        else:
            ans = min(abs(sumA[i] * 2 - sumA[-1]), abs(sumA[i-1] * 2 - sumA[-1]))
            break
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split(' ')))

def sum(a, b):
    if b == 0:
        return a[b]
    else:
        return a[b] + sum(a, b-1)
sumA = []
for i in range(N):
    sumA.append(sum(A, i))

ans = 0

for i in range(N):
    if sumA[-1] // 2 > sumA[i]:
        continue
    else:
        if i == 0:
            ans = abs(sumA[i] * 2 - sumA[-1])
            break
        else:
            ans = min(abs(sumA[i] * 2 - sumA[-1]), abs(sumA[i-1] * 2 - sumA[-1]))
            break

print(ans)

Fixed submission:
import sys
    
sys.setrecursionlimit(200000)
    
N = int(input())
A = list(map(int, input().split(' ')))
    

sumA = []
for i in range(N):
    if i == 0:
        sumA.append(A[i])
    else:
        sumA.append(sumA[-1] + A[i])
    
ans = 0
    
for i in range(N):
    if sumA[-1] // 2 > sumA[i]:
        continue
    else:
        if i == 0:
            ans = abs(sumA[i] * 2 - sumA[-1])
            break
        else:
            ans = min(abs(sumA[i] * 2 - sumA[-1]), abs(sumA[i-1] * 2 - sumA[-1]))
            break
    
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split(' ')))

def sum(a, b):
    if b == 0:
        return a[b]
    else:
        return a[b] + sum(a, b-1)
sumA = []
for i in range(N):
    sumA.append(sum(A, i))

ans = 0

for i in range(N):
    if sumA[-1] // 2 > sumA[i]:
        continue
    else:
        if i == 0:
            ans = abs(sumA[i] * 2 - sumA[-1])
            break
        else:
            ans = min(abs(sumA[i] * 2 - sumA[-1]), abs(sumA[i-1] * 2 - sumA[-1]))
            break

print(ans)

Fixed submission:
import sys
    
sys.setrecursionlimit(200000)
    
N = int(input())
A = list(map(int, input().split(' ')))
    

sumA = []
for i in range(N):
    if i == 0:
        sumA.append(A[i])
    else:
        sumA.append(sumA[-1] + A[i])
    
ans = 0
    
for i in range(N):
    if sumA[-1] // 2 > sumA[i]:
        continue
    else:
        if i == 0:
            ans = abs(sumA[i] * 2 - sumA[-1])
            break
        else:
            ans = min(abs(sumA[i] * 2 - sumA[-1]), abs(sumA[i-1] * 2 - sumA[-1]))
            break
    
print(ans)