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


diff = 2020202020 * 200000 + 1
tot = sum(A)

for i in range(N):
    temp1 = A[:i+1]
    # temp2 = A[i+1:]
    temp3 = abs(tot - 2 * sum(temp1))
    if temp3 <= diff:
        # mid = i
        diff = temp3
    else:
        break

print(diff)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))


diff = 2020202020 * 200000 + 1
tot = sum(A)

temp1 = 0

for i in range(N):
    temp1 += A[i]
    # temp2 = A[i+1:]
    temp3 = abs(tot - 2 * temp1)
    if temp3 <= diff:
        # mid = i
        diff = temp3
    else:
        break

print(diff)

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


def loop():
    diff = 2020202020 * 200000 + 1
    tot = sum(A)
    for i in range(N):
        temp1 = A[:i+1]
        # temp2 = A[i+1:]
        temp3 = abs(tot - 2 * sum(temp1))
        if temp3 <= diff:
            # mid = i
            diff = temp3

    print(diff)

loop()


Fixed submission:
N = int(input())
A = list(map(int,input().split()))


diff = 2020202020 * 200000 + 1
tot = sum(A)

temp1 = 0

for i in range(N):
    temp1 += A[i]
    # temp2 = A[i+1:]
    temp3 = abs(tot - 2 * temp1)
    if temp3 <= diff:
        # mid = i
        diff = temp3
    else:
        break

print(diff)

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

diff = 2020202020 * 200000 + 1

tot = sum(A)

for i in range(N):
    temp1 = A[:i+1]
    # temp2 = A[i+1:]
    temp3 = abs(tot - 2 * sum(temp1))
    if temp3 <= diff:
        # mid = i
        diff = temp3

print(diff)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))


diff = 2020202020 * 200000 + 1
tot = sum(A)

temp1 = 0

for i in range(N):
    temp1 += A[i]
    # temp2 = A[i+1:]
    temp3 = abs(tot - 2 * temp1)
    if temp3 <= diff:
        # mid = i
        diff = temp3
    else:
        break

print(diff)

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

diff = 2020202020 * 200000 + 1

for i in range(N):
    temp1 = A[:i+1]
    temp2 = A[i+1:]
    temp3 = abs(sum(temp2) - sum(temp1))
    if temp3 <= diff:
        mid = i
        diff = temp3

print(diff)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))


diff = 2020202020 * 200000 + 1
tot = sum(A)

temp1 = 0

for i in range(N):
    temp1 += A[i]
    # temp2 = A[i+1:]
    temp3 = abs(tot - 2 * temp1)
    if temp3 <= diff:
        # mid = i
        diff = temp3
    else:
        break

print(diff)

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

diff = 2020202020 * 200000 + 1

for i in range(N):
    temp1 = A[:i+1]
    temp2 = A[i+1:]
    temp3 = abs(sum(temp2) - sum(temp1))
    if temp3 <= diff:
        mid = i
        diff = temp3

print(diff)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))


diff = 2020202020 * 200000 + 1
tot = sum(A)

temp1 = 0

for i in range(N):
    temp1 += A[i]
    # temp2 = A[i+1:]
    temp3 = abs(tot - 2 * temp1)
    if temp3 <= diff:
        # mid = i
        diff = temp3
    else:
        break

print(diff)