Buggy python submission (verdict: Runtime Error):
N=int(input())
a=input().split()
A=[int(b) for b in a]
first=A[0]
last=A[-1]
if N==2:
    print(abs(first-last))
else:
    average = sum(A) // 2
    number = 0
    del A[0]
    del A[-1]
    for a in range(N - 1):
        number += A[a]
        if number >= average:
            break
    a1 = abs(sum(A[:a]) + first - last - sum(A[a:]))
    a2 = abs(sum(A[:a + 1]) + first - last - sum(A[a + 1:]))
    print(min(a1, a2))


Fixed submission:
N=int(input())
a=input().split()
a=[int(b) for b in a]
numbers=[]
number=0
for a_ in a:
    number+=a_
    numbers.append(number)
del numbers[-1]
if N==2:
    print(abs(a[0]-a[1]))
else:
    whole=sum(a)
    answers=[]
    for number in numbers:
        answer=abs(number*2-whole)
        answers.append(answer)
    print(min(answers))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=input().split()
A=[int(b) for b in a]
whole=sum(A)
answers=[]
for n in range(1,N):
    first=sum(A[:n])
    last=whole-first
    answers.append(abs(first-last))
print(min(answers))


Fixed submission:
N=int(input())
a=input().split()
a=[int(b) for b in a]
numbers=[]
number=0
for a_ in a:
    number+=a_
    numbers.append(number)
del numbers[-1]
if N==2:
    print(abs(a[0]-a[1]))
else:
    whole=sum(a)
    answers=[]
    for number in numbers:
        answer=abs(number*2-whole)
        answers.append(answer)
    print(min(answers))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=input().split()
A=[int(b) for b in a]
answers=[]
for n in range(1,N):
    first=sum(A[:n])
    last=sum(A[n:])
    answers.append(abs(first-last))
print(min(answers))


Fixed submission:
N=int(input())
a=input().split()
a=[int(b) for b in a]
numbers=[]
number=0
for a_ in a:
    number+=a_
    numbers.append(number)
del numbers[-1]
if N==2:
    print(abs(a[0]-a[1]))
else:
    whole=sum(a)
    answers=[]
    for number in numbers:
        answer=abs(number*2-whole)
        answers.append(answer)
    print(min(answers))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=input().split()
cards=[int(b) for b in a]
whole=sum(cards)
answers=[]
for c in range(N-1):
    sunuke=cards[:c+1]
    goukei=sum(sunuke)
    answers.append(abs(whole-goukei*2))
print(min(answers))


Fixed submission:
N=int(input())
a=input().split()
a=[int(b) for b in a]
numbers=[]
number=0
for a_ in a:
    number+=a_
    numbers.append(number)
del numbers[-1]
if N==2:
    print(abs(a[0]-a[1]))
else:
    whole=sum(a)
    answers=[]
    for number in numbers:
        answer=abs(number*2-whole)
        answers.append(answer)
    print(min(answers))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=input().split()
cards=[int(b) for b in a]
whole=sum(cards)
answers=[]
for c in range(len(cards)-1):
    sunuke=cards[:c+1]
    goukei=sum(sunuke)
    answers.append(abs(whole-goukei*2))
print(min(answers))


Fixed submission:
N=int(input())
a=input().split()
a=[int(b) for b in a]
numbers=[]
number=0
for a_ in a:
    number+=a_
    numbers.append(number)
del numbers[-1]
if N==2:
    print(abs(a[0]-a[1]))
else:
    whole=sum(a)
    answers=[]
    for number in numbers:
        answer=abs(number*2-whole)
        answers.append(answer)
    print(min(answers))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=input().split()
cards=[int(b) for b in a]
whole=sum(cards)
answers=[]
for c in range(len(cards)-1):
    sunuke=cards[:c+1]
    goukei=sum(sunuke)
    answers.append(abs(whole-goukei*2))
print(min(answers))


Fixed submission:
N=int(input())
a=input().split()
a=[int(b) for b in a]
numbers=[]
number=0
for a_ in a:
    number+=a_
    numbers.append(number)
del numbers[-1]
if N==2:
    print(abs(a[0]-a[1]))
else:
    whole=sum(a)
    answers=[]
    for number in numbers:
        answer=abs(number*2-whole)
        answers.append(answer)
    print(min(answers))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=input().split()
cards=[int(b) for b in a]
answers=[]
for c in range(len(cards)-1):
    sunuke=cards[:c+1]
    arai=cards[c+1:]
    answers.append(abs(sum(sunuke)-sum(arai)))
print(min(answers))


Fixed submission:
N=int(input())
a=input().split()
a=[int(b) for b in a]
numbers=[]
number=0
for a_ in a:
    number+=a_
    numbers.append(number)
del numbers[-1]
if N==2:
    print(abs(a[0]-a[1]))
else:
    whole=sum(a)
    answers=[]
    for number in numbers:
        answer=abs(number*2-whole)
        answers.append(answer)
    print(min(answers))