ZhenlongDai/ACPR huggingface dataset:
Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
l = list(map(int,input().split()))
ans = 100000000000000
x = 0
S = sum(l)
for i in range(N):
  x = x + l[i]
  ans = min(ans, abs(x - (S - x)))
  print(ans)
 
print(ans)

Failing test case input:
6
0 3 3 7 1 8

Expected output:
4


Actual output:
22
16
10
4
4
4
4


Fixed submission (verdict: Accepted):
N = int(input())
l = list(map(int,input().split()))
ans = 100000000000000
x = 0
S = sum(l)
for i in range(N-1):
  
  x = x + l[i]
  
  ans = min(ans, abs(x - (S - x)))
  
print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
S = []
s = 0


for i in range(N-1):
  s += A[i]
  S.append(s)

s = sum(A) 

for i in range(N-1):
  S[i] = abs(S[i] - s)
print(min(S))

Failing test case input:
2
-1 -89

Expected output:
88


Actual output:
89


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
S = []
s = 0


for i in range(N-1):
  s += A[i]
  S.append(s)


s = sum(A) 


h = s/2
m = 10000000000
index = 0

for i in range(N-1):
  if abs(S[i] - h) < m:
    m = abs(S[i] - h)
    index = i
    
print(abs(s-S[index]*2))

Problem: p03659
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
ans=float("inf")
x=0
b=sum(a)
for i in range(n):
    x+=a[1]
    ans=min(ans,abs(b-2*x))    
print(ans)

Failing test case input:
2
-74 -1

Expected output:
73


Actual output:
71


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
ans=float("inf")
x=0
b=sum(a)
for i in range(n):
    x+=a[i]
    if i+1<n:
        ans=min(ans,abs(b-2*x))    
print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
m=list(map(int,input().split()))
a=sum(m)
for i in range(1,n):
  m[i]+=m[i-1]
ans=99999999
for i in m:
  ans=min(ans,abs(a-i-i))
print(ans)

Failing test case input:
2
-39 1

Expected output:
40


Actual output:
38


Fixed submission (verdict: Accepted):
n=int(input())
m=list(map(int,input().split()))
a=sum(m)
for i in range(1,n):
  m[i]+=m[i-1]
ans=99999999999999
for i in m[:n-1]:
  ans=min(ans,abs(a-i-i))
print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


N=int(input())
b=input()
c=b.split(" ")
d=map(int,c)
a=list(d)
X=sum(a)
ans=[]
for i in range(N-1):
    A=2*a[i]
    if i ==0:
        ans.append(X-A)
    else:
        B=abs(ans[i-1]-A)
        ans.append(B)
ans1=min(ans)
print(ans1)

Failing test case input:
2
23 0

Expected output:
23


Actual output:
-23


Fixed submission (verdict: Accepted):


N=int(input())
b=input()
c=b.split(" ")
d=map(int,c)
a=list(d)
X=sum(a)
ans=[]
Y=0
for i in range(N-1):

    Y=Y+a[i]
    B=abs(X-2*Y)
    ans.append(B)
ans1=min(ans)
print(ans1)
Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
A = sum(a[:n-1:])-a[n-1]
c = 10*9
c = min(c,A)
if n == 2:
    print(abs(a[0]-a[1]))
else:
    for i in range(1,n-1):
        A=A-2*a[n-i]
        c = min(c,abs(A))
    print(c)

Failing test case input:
6
0 2 3 4 5 6

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
A = sum(a[:n-1])-a[n-1]
c = n*(10**9)
c = min(c,abs(A))
if n == 2:
    print(abs(a[0]-a[1]))
else:
    for i in range(1,n-2):
        A=A-2*a[n-1-i]
        c = min(c,abs(A))
    print(c)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = [int(x) for x in input().split()]

ans = sum(a) - 2*a[0]
temp = abs(ans)
for i in range(1,N-1):
    temp -= 2*a[i]
    if ans > abs(temp): ans = abs(temp)

print(ans)

Failing test case input:
2
-1 -33

Expected output:
32


Actual output:
-32


Fixed submission (verdict: Accepted):
N = int(input())
a = [int(x) for x in input().split()]

temp = sum(a) - 2*a[0]
ans = abs(temp)
for i in range(1,N-1):
    temp -= 2*a[i]
    if ans > abs(temp): ans = abs(temp)

print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
A = list(map(int, input().split()))
card = sum([abs(a) for a in A])
d = card
snuke = 0
for a in A:
    snuke += a
    d = min(d, abs(card-snuke*2))
print(d)

Failing test case input:
2
-4 -126

Expected output:
122


Actual output:
130


Fixed submission (verdict: Accepted):
n = int(input())
A = list(map(int, input().split()))
card = sum(A)
d = sum([abs(a) for a in A])
snuke = 0
for i in range(n-1):
    snuke += A[i]
    d = min(d, abs(card-snuke*2))
print(d)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = list(map(int, input().split()))

X = sum(a)

ans = []
for i in range(N):
    ans.append(X - 2*sum(a[:i]))

print(min(ans))


Failing test case input:
2
-77 1

Expected output:
78


Actual output:
-76


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int, input().split()))

X = sum(a)
b = [a[0]]
for i in range(1, N - 1):
    b.append(b[i-1] + a[i])

ans = []
for i in range(0, N - 1):
    ans.append(abs(X - 2*b[i]))

print(min(ans))

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
sum_A = sum(A)
x, y = 0, 0
ans = 10**9
for i in range(N):
  x += A[i]
  y = sum_A - x
  ans = min(ans, abs(x-y))
print(ans)

Failing test case input:
2
-25 2

Expected output:
27


Actual output:
23


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
sum_A = sum(A)
x, y = 0, 0
ans = 10**20
for i in range(N-1):
  x += A[i]
  y = sum_A - x
  ans = min(ans, abs(x-y))
print(ans)
Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
L = sorted(list(map(int,input().split())))
sum1 = 0
sum2 = sum(L)
ans = 10**10
for i in range(n):
    sum1 += L[i]
    sum2 -= L[i]
    ans = min(ans,abs(sum1 - sum2))

print(ans)

Failing test case input:
2
-25 2

Expected output:
27


Actual output:
23


Fixed submission (verdict: Accepted):
n = int(input())
L = list(map(int,input().split()))
sum1 = sum(L)
sum2 = 0

if n == 2:
    print(abs(L[1]-L[0]))
    exit ()
ans = 10**20
for i in range(n-1):
    sum2 +=L[i]
    sa = abs(sum1 - sum2- sum2)
    ans = min(ans,sa)
print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(i) for i in input().split()]

A = sorted(A)
ans = A[len(A)-1]
for i in range(len(A)-2, -1, -1):
    ans = abs(ans - A[i])
print(ans)

Failing test case input:
6
1 2 3 7 8 13

Expected output:
8


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(i) for i in input().split()]

A_sum = sum(A)
check = 0
ans = 10 ** 18
for i in range(N-1):
    check += A[i]
    ans = min(abs(check - (A_sum - check)), ans)
print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n = int(input())
a = list(map(int,input().split()))
sss = 0
for i in range(n):
    sss=sss + a[i]
ppp = 0
qqq = abs(sss - 2 * a[0])
for i in range(n):
    ppp=ppp + a[i]
    qo = abs(sss-2*ppp)
    if qqq > qo:
        qqq=qo
        
print(qqq)

Failing test case input:
2
-163 1

Expected output:
164


Actual output:
162


Fixed submission (verdict: Accepted):

n = int(input())
a = list(map(int,input().split()))
sss = 0
for i in range(n):
    sss=sss + a[i]
ppp = 0
qqq = abs(sss - 2 * a[0])
for i in range(n-1):
    ppp=ppp + a[i]
    qo = abs(sss-2*ppp)
    if qqq > qo:
        qqq=qo
        
print(qqq)

Problem: p03659
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
A = list(map(int, input().split()))
min_abs = 1000000000000000000000000
for i in range(1, n):
  A[i] += A[i-1]

for i in range(n):
  abs_val = abs(A[n-1] - A[i] * 2)
  min_abs = min(min_abs, abs_val)
print(min_abs)

Failing test case input:
2
-39 1

Expected output:
40


Actual output:
38


Fixed submission (verdict: Accepted):
n = int(input())
A = list(map(int, input().split()))
min_abs = 1000000000000000000000000
for i in range(1, n):
  A[i] += A[i-1]

for i in range(0, n-1):
  abs_val = abs(A[-1] - (A[i] * 2))
  min_abs = min(min_abs, abs_val)
print(min_abs)

Problem: p03659
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

m = sum(a)
ans = 0
s = float("inf")
t = 0
for i in range(n-1):
  t += a[i]
  if  abs(m-t) <= s:
    s = abs(m-t)
    ans = i+1
  else: break

print(abs(sum(a[:ans]) - sum(a[ans:])))

Failing test case input:
6
0 3 3 7 1 8

Expected output:
4


Actual output:
6


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))

s = sum(a)
t = 0
ans = float("inf")

for i in range(n-1):
  t += a[i]
  s -= a[i]
  ans = min(ans, abs(s-t))
print(ans)
Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
X = sum(a)
ans = 10*20
x = 0
for i in range(n-1):
    x +=a[i]
    ans = min(ans,abs(X-2*x))
print(ans)
    


Failing test case input:
2
-259 1

Expected output:
260


Actual output:
200


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
X = sum(a)
ans = 10**50
x = 0
for i in range(n-1):
    x +=a[i]
    ans = min(ans,abs(X-2*x))
print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
a = list(map(int, input().split()))


def cum(array):
    result = [0]
    for i in range(len(array)):
        result.append(array[i]+result[i])
    return result


cumArray = cum(a)
print(cumArray)

ans = 10**12
for i in range(1, n):
    
    
    ans = min(ans, abs(cumArray[n]-2*cumArray[i]))

print(ans)


Failing test case input:
6
0 3 3 7 1 8

Expected output:
4


Actual output:
[0, 0, 3, 6, 13, 14, 22]
4


Fixed submission (verdict: Accepted):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
a = list(map(int, input().split()))


def cum(array):
    result = [0]
    for i in range(len(array)):
        result.append(array[i]+result[i])
    return result


cumArray = cum(a)


ans = 10**12
for i in range(1, n):
    
    
    ans = min(ans, abs(cumArray[n]-2*cumArray[i]))

print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

a_sum = sum(a)
x = 0
y = a_sum
min_diff = a_sum

for i in range(n):
    x += a[i]
    y -= a[i]
    diff = abs(y - x)
    if diff < min_diff:
        min_diff = diff

print(min_diff)

Failing test case input:
2
-5 -89

Expected output:
84


Actual output:
-94


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))

a_sum = sum(a)
x = a[0]
y = a_sum - x
min_diff = 10000000000
diff = abs(y - x)

for i in range(1, n-1):
    x += a[i]
    y -= a[i]
    diff = abs(y - x)
    if diff < min_diff:
        min_diff = diff

if diff < min_diff:
    min_diff = diff
print(min_diff)

Problem: p03659
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
l=list(map(int,input().split()))
mae=[0]*n
usi=[0]*n
ma=0
for i in range(n):
    ma+=l[i]
    mae[i]=ma
us=0
for i in range(n-1,-1,-1):
    us+=l[i]
    usi[i]=us
ans=10000000000000000000
for i in range(1,n-1):
    ans=min(ans,abs(mae[i]-usi[i]))
print(ans)

Failing test case input:
2
23 0

Expected output:
23


Actual output:
10000000000000000000


Fixed submission (verdict: Accepted):
n=int(input())
l=list(map(int,input().split()))
mae=[0]*n
usi=[0]*n
ma=0
for i in range(n):
    ma+=l[i]
    mae[i]=ma
us=0
for i in range(n-1,-1,-1):
    us+=l[i]
    usi[i]=us
ans=10000000000000000000
for i in range(0,n-1):
    ans=min(ans,abs(mae[i]-usi[i+1]))
    
print(ans)
Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
A = list(map(int, input().split()))

ans = 10**18
for i in range(n):
    can = abs(sum(A[:i]) - sum(A[i:]))
    if can <= ans:
        ans = can

print(ans)


Failing test case input:
2
-47 1

Expected output:
48


Actual output:
46


Fixed submission (verdict: Accepted):
n = int(input())
A = list(map(int, input().split()))

ans = 10**18
Rui = []
r = 0
for i in range(n):
    r += A[i]
    Rui.append(r)

for i in range(0,n-1):
    can = abs(2 * Rui[i] - Rui[-1])
    if can <= ans:
        ans = can
print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

tot = sum(A)

res = 0
s, t = A[0], sum(A[1:])
min_dif = abs(s - t)
for a in A[1:-1]:
    s += a
    t -= a
    dif = abs(s - t)
    if min_dif > dif:
        min_dif = dif
    else:
        print(dif)
        exit()

print(abs(s - A[-1]))


Failing test case input:
6
-1 10 3 3 1 8

Expected output:
0


Actual output:
6


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

tot = sum(A)
half = tot / 2
res = 0
s, t = A[0], sum(A[1:])
min_v = abs(s - t)

for a in A[1:-1]:

    s += a
    tmp = abs(tot - 2 * s)
    if tmp < min_v:
        min_v = tmp

print(min_v)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))
B = list(accumulate(A))
S = B[-1]

ans = float('inf')
for i in range(1, N-1):
  x = B[i]
  y = S - x
  ans = min(ans, abs(x - y))

print(ans)

Failing test case input:
2
-119 1

Expected output:
120


Actual output:
inf


Fixed submission (verdict: Accepted):
from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))
B = list(accumulate(A))
S = B[-1]

ans = float('inf')
for i in range(N-1):
  x = B[i]
  y = S - x
  ans = min(ans, abs(x - y))

print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))

ans=1000000000000000
B=[A[0]]
for i in range(1,N):
    B.append(B[i-1]+A[i])

S=sum(A)

for j in range(N-1):
    if abs(S-B[j])<ans:
        ans=abs((S-B[j])-B[j])
print(ans)

Failing test case input:
6
-1 10 3 3 1 8

Expected output:
0


Actual output:
6


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))
S=sum(A)
B=[A[0]]
for j in range(1,N):
    B.append(B[j-1]+A[j])


ans=10000000000
for i in range(N-1):
    ans=min(abs((S-B[i])-B[i]),ans)
print(ans)

Problem: p03659
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))

f=0
b=sum(a)
m=b
for x in a:
    f+=x
    b-=x
    m=min(m,abs(f-b))
print(m)

Failing test case input:
2
-77 2

Expected output:
79


Actual output:
-75


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))

f=0
b=sum(a)
m=abs(a[0]-sum(a[1:]))
for i in range(n-1):
    f+=a[i]
    b-=a[i]
    m=min(m,abs(f-b))
print(m)
Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def splittingplie(n , a):

    ans = 100000000000000
    sumlist = [0]*n

    for i in range(n):
        if i == 0:
            sumlist[i] += a[i]
        else:
            sumlist[i] += a[i] + sumlist[i-1]

    for i in range(n):
        rldifference = abs(int(sumlist[i]) - (sumlist[-1] - sumlist[i]))
        ans = min(ans , rldifference)
    return ans

def main():
    n = int(input())
    a = list(map(int , input().split()))
    print(splittingplie(n , a))

if __name__ == '__main__':
    main()

Failing test case input:
2
-64 1

Expected output:
65


Actual output:
63


Fixed submission (verdict: Accepted):
def splittingplie(n , a):

    ans = 10**18
    allsum = int(sum(a))
    asum = 0

    for i in range(n - 1):
        asum += a[i]
        rldifference = abs(allsum - asum*2)
        ans = min(ans , rldifference)

    return ans

def main():
    n = int(input())
    a = list(map(int , input().split()))
    print(splittingplie(n , a))

if __name__ == '__main__':
    main()

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
card = list(map(int,input().split(' ')))

sum_card = sum(card)
min_value = 1000000000
sunuke = card[0]
for i in range(1,N-1,1):
  sunuke += card[i]
  if abs(sum_card - 2*sunuke) < min_value:
    min_value = abs(sum_card - 2*sunuke)
  
print(int(min_value))

Failing test case input:
2
-1 -30

Expected output:
29


Actual output:
1000000000


Fixed submission (verdict: Accepted):
N = int(input())
card = list(map(int,input().split(' ')))

sum_card = sum(card)
min_value = 10000000000
sunuke = 0
for i in range(0,N-1,1):
  sunuke += card[i]
  if abs(sum_card - 2*sunuke) < min_value:
    min_value = abs(sum_card - 2*sunuke)
  
print(int(min_value))

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



import sys

N = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split(' ')))

snk = 0
arg = 0

for i in range(0, N):
	arg += a[i]

s = arg

for i in range(0, N - 1):
	snk += a[i]
	arg -= a[i]
	ss = snk - arg
	if ss < 0:
		ss *= -1

	if s > ss:
		s = ss

print(s)

Failing test case input:
2
10 -10

Expected output:
20

Actual output:
0


Fixed submission (verdict: Accepted):



import sys

N = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split(' ')))

snk = 0
arg = 0

for i in range(0, N):
	arg += a[i]

s = 100000000000000

for i in range(0, N - 1):
	snk += a[i]
	arg -= a[i]
	ss = snk - arg
	if ss < 0:
		ss *= -1

	if s > ss:
		s = ss

print(s)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
sa=0
sb=sum(a)
d=10**9
for i in range(1,n-1):
  sa+=a[i]
  sb-=a[i]
  d=min(abs(sa-sb),d)
print(d)


Failing test case input:
2
-77 1

Expected output:
78


Actual output:
1000000000


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
sa=a[0]
d=abs(s-2*a[n-1])
for i in range(1,n-1):
  sa+=a[i]
  d=min(abs(s-sa-sa),d)
print(d)
Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
X = sum(a)
ans = 10*20
for i in range(n-1):
    x = sum(a[:i+1])
    ans = min(ans,abs(X-2*x))
print(ans)
    


Failing test case input:
2
-259 1

Expected output:
260


Actual output:
200


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
X = sum(a)
ans = 10**50
x = 0
for i in range(n-1):
    x +=a[i]
    ans = min(ans,abs(X-2*x))
print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [int(i) for i in input().split()]
sumA = 0
sumli = sum(a)
ans = 1000000000
for i in range(n):
    sumA += a[i]
    sumB = abs(sumli - sumA*2)
    ans = min(ans,sumB)
print(ans)

Failing test case input:
2
86 -1

Expected output:
87


Actual output:
85


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(i) for i in input().split()]
sumA = 0
sumli = sum(a)
ans = 1000000000
for i in range(n-1):
    sumA += a[i]
    sumB = abs(sumli - sumA*2)
    ans = min(ans,sumB)
if n == 2:
    print(abs(a[0]-a[1]))
else:
    print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


N=int(input())
b=input()
c=b.split(" ")
d=map(int,c)
a=list(d)
X=sum(a)
ans=[]
for i in range(N-1):
    A=abs(X-2*a[i])
    if i ==0:
        ans.append(A)
    else:
        B=ans[i-1]+A
        ans.append(B)
ans1=min(ans)
print(ans1)

Failing test case input:
6
0 6 3 4 1 8

Expected output:
4


Actual output:
22


Fixed submission (verdict: Accepted):


N=int(input())
b=input()
c=b.split(" ")
d=map(int,c)
a=list(d)
X=sum(a)
ans=[]
Y=0
for i in range(N-1):

    Y=Y+a[i]
    B=abs(X-2*Y)
    ans.append(B)
ans1=min(ans)
print(ans1)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
cards = list(map(int, input().split()))
y = sum(cards[1:])
x = cards[0]
ans = float("inf")
for i in range(N):
    x += cards[i]
    y -= cards[i]
    if(abs(x-y) < ans):
        ans = abs(x-y)
print(ans)

Failing test case input:
2
-22 3

Expected output:
25


Actual output:
63


Fixed submission (verdict: Accepted):
N = int(input())
cards = list(map(int, input().split()))
ans = float("inf")
y = sum(cards)
x = 0
L = []

for card in cards:
    x += card
    y -= card
    L.append(abs(x-y))
    
del L[N-1]

print(min(L))

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A=list(map(int, input().split()))
if N==2:
    print(abs(A[0]-A[1]))
    exit()
SUM=sum(A)
x=0
now=0
for i in range(N-1):
    now+=A[i]
    if abs(SUM-now)<abs(SUM-x):
        x=now
y=SUM-x
print(abs(x-y))

Failing test case input:
6
0 10 3 3 1 8

Expected output:
1


Actual output:
9


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int, input().split()))
if N==2:
    print(abs(A[0]-A[1]))
    exit()
SUM=sum(A)
ans=float("INF")
now=0
for i in range(N-1):
    now+=A[i]
    ans=min(ans, abs(now-(SUM-now)))


print(ans)
Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
an=list(map(int,input().split()))
s=sum(an)
b = an[0]

l=[]
a = abs(s-2*b)
for i in range(1,N):
    b = b + an[i]
    a=min(a,abs(s-2*b))
print(a)

Failing test case input:
2
-108 2

Expected output:
110


Actual output:
106


Fixed submission (verdict: Accepted):
N=int(input())
an=list(map(int,input().split()))
s=sum(an)
b = an[0]

l=[]
a = abs(s-2*b)
for i in range(1,N-1):
    b = b + an[i]
    a=min(a,abs(s-2*b))
print(a)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n):
    a[i]+=a[i-1]
ABS=10*15
for i in range(n-1):
    ABS=min(abs(a[-1]-2*a[i]),ABS)
print(ABS)

Failing test case input:
2
-163 1

Expected output:
164


Actual output:
150


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n):
    a[i]+=a[i-1]
ABS=10**15
for i in range(n-1):
    ABS=min(abs(a[-1]-2*a[i]),ABS)
print(ABS)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n):
    a[i]+=a[i-1]
ABS=10*15
for i in range(n-1):
    ABS=min(abs(a[n-1]-2*a[i]),ABS)
print(ABS)

Failing test case input:
2
-259 1

Expected output:
260


Actual output:
150


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n):
    a[i]+=a[i-1]
ABS=10**15
for i in range(n-1):
    ABS=min(abs(a[-1]-2*a[i]),ABS)
print(ABS)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=[int(i) for i in input().split()]

x=a[0]
y=sum(a[1:])
m=abs(x - y)

i=1

while i < n:
  x+=a[i]
  y-=a[i]
  m = min(abs(x - y),m)
  i+=1
print(m)


Failing test case input:
2
86 -1

Expected output:
87


Actual output:
85


Fixed submission (verdict: Accepted):
n=int(input())
a=[int(i) for i in input().split()]

x=a[0]
y=sum(a[1:])
m=abs(x - y)

i=1

while i < n-1:
  x+=a[i]
  y-=a[i]
  m = min(abs(x - y),m)
  i+=1
print(m)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
snuke = a[0]
ans = abs(s - snuke * 2)
for x in a[1:n-1]:
  snuke += x
  ans = min(ans, s - snuke * 2)
print(ans)

Failing test case input:
6
0 3 3 7 1 13

Expected output:
1


Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
snuke = a[0]
ans = abs(s - snuke * 2)
for x in a[1:n-1]:
  snuke += x
  ans = min(ans, abs(s - snuke * 2))
print(ans)
Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = list(map(int, input().split()))

X = sum(a)
b = [a[0]]
for i in range(1, N):
    b.append(a[i-1] + a[i])

ans = []
for i in range(1, N):
    ans.append(abs(X - 2*b[i]))

print(min(ans))


Failing test case input:
2
-13 3

Expected output:
16


Actual output:
10


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int, input().split()))

X = sum(a)
b = [a[0]]
for i in range(1, N - 1):
    b.append(b[i-1] + a[i])

ans = []
for i in range(0, N - 1):
    ans.append(abs(X - 2*b[i]))

print(min(ans))

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


N=int(input())
b=input()
c=b.split(" ")
d=map(int,c)
a=list(d)
X=sum(a)
ans=[]
for i in range(N):
    A=abs(X-2*sum(a[0:i+1]))
    ans.append(A)
ans1=min(ans)
print(ans1)

Failing test case input:
2
-47 2

Expected output:
49


Actual output:
45


Fixed submission (verdict: Accepted):


N=int(input())
b=input()
c=b.split(" ")
d=map(int,c)
a=list(d)
X=sum(a)
ans=[]
Y=0
for i in range(N-1):

    Y=Y+a[i]
    B=abs(X-2*Y)
    ans.append(B)
ans1=min(ans)
print(ans1)

Problem: p03659
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))

total = sum(a)
s = 0
i = 0
ans = total + 1
for i in range(n):
    s += a[i]
    total -= a[i]
    ans = min(ans, abs(s - total))
    i += 1
print(ans)


Failing test case input:
2
-2 -126

Expected output:
124


Actual output:
-127


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))

s = a[0]
t = sum(a) - a[0]

i = 0
ans = abs(s - t)
for i in range(1, n-1):
    s += a[i]
    t -= a[i]
    ans = min(ans, abs(s - t))
    i += 1
print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 20


def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    total = sum(a_list)

    dp1 = [0] * N
    dp1[0] = a_list[0]
    for i in range(1, N):
        dp1[i] = a_list[i] + dp1[i - 1]

    ans = INF
    for i in range(N - 1):
        ans = min(ans, abs(total - dp1[i]))
    print(ans)


if __name__ == '__main__':
    main()


Failing test case input:
2
51 0

Expected output:
51


Actual output:
0


Fixed submission (verdict: Accepted):
from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 20


def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    total = sum(a_list)

    dp1 = [0] * N
    dp1[0] = a_list[0]
    for i in range(1, N):
        dp1[i] = a_list[i] + dp1[i - 1]

    ans = INF
    for i in range(N - 1):
        ans = min(ans, abs(dp1[i] - (total - dp1[i])))
    print(ans)


if __name__ == '__main__':
    main()
Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
input_list = [int(i) for i in input().split()]

index = 1
ruiseki_list = [0]*(N+1)
result = 10*9

if N == 2:
    print(abs(input_list[0]-input_list[1]))
else:
    for i in input_list:
        ruiseki_list[index] = ruiseki_list[index-1] + i
        index += 1

    for i in range(2, N):
        cal = abs(ruiseki_list[N] - 2 * ruiseki_list[i])
        print(cal)
        if cal < result:
            result = cal
    print(result)

Failing test case input:
6
0 2 3 7 5 6

Expected output:
1


Actual output:
19
13
1
11
1


Fixed submission (verdict: Accepted):
N = int(input())
input_list = [int(i) for i in input().split()]

index = 1
ruiseki_list = [0]*(N+1)
result = 10*9

if N == 2:
    print(abs(input_list[0]-input_list[1]))
else:
    for i in input_list:
        ruiseki_list[index] = ruiseki_list[index-1] + i
        index += 1

    mapped_list = map(lambda x: ruiseki_list[N]-x, ruiseki_list)
    result_list = [abs(a-b) for (a, b) in zip(ruiseki_list, mapped_list)]
    print(min(result_list[2:N]))

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))

s = [0]*(n-1)
s[0] = a[0]
A = sum(a)
ans = 1e100
for i in range(n-2):
  s[i+1] = s[i] + a[i+1]

for t in s:
  ans = min(ans, abs(2*t - A))

Failing test case input:
2
-68 0

Expected output:
68


Actual output:

Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))

s = [0]*(n-1)
s[0] = a[0]
A = sum(a)
ans = 1e100
for i in range(n-2):
  s[i+1] = s[i] + a[i+1]

for t in s:
  ans = min(ans, abs(2*t - A))
print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
a = sorted(a,reverse=True)
x = a[0]
y = a[1]
for i in range(2,n):
    if x >= y:
        y += a[i]
    else:
        x += a[i]
print(abs(x-y))

Failing test case input:
6
-1 2 3 7 5 6

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
s1 = sum(a) - a[0]
s2 = a[0]
m = abs(s1-s2)
for i in range(1,n-1):
    s1 -= a[i]
    s2 += a[i]
    m = min(m,abs(s1-s2))
print(m)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
cards = list(map(int, input().split()))
y = sum(cards[1:])
x = cards[0]
ans = float("inf")
for card in cards:
    print(card)
    x += card
    y -= card
    if(abs(x-y) < ans):
        ans = abs(x-y)
print(ans)

Failing test case input:
6
0 10 3 3 1 8

Expected output:
1


Actual output:
0
10
3
3
1
8
1


Fixed submission (verdict: Accepted):
N = int(input())
cards = list(map(int, input().split()))
ans = float("inf")
y = sum(cards)
x = 0
L = []

for card in cards:
    x += card
    y -= card
    L.append(abs(x-y))
    
del L[N-1]

print(min(L))
Problem: p03659
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def solve():
    N = int(input())
    A = list(map(int, input().split()))

    y = sum(A)
    x = 0
    mn = float('inf')
    for a in A:
        x += a
        y -= a
        if y != 0:
            mn = min(mn, abs(x-y))
    
    print(mn)

if __name__ == '__main__':
    solve()

Failing test case input:
2
23 0

Expected output:
23


Actual output:
inf


Fixed submission (verdict: Accepted):
def solve():
    N = int(input())
    A = list(map(int, input().split()))

    y = sum(A)
    x = 0
    mn = float('inf')
    for i in range(N-1):
        x += A[i]
        y -= A[i]
        mn = min(mn, abs(x-y))
    
    print(mn)

if __name__ == '__main__':
    solve()

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):






from sys import stdin,setrecursionlimit





setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
a=[int(i) for i in input().split()]
card=sum(a)
snuke=0
ans=10**10
for i in range(n):
    snuke+=a[i]
    ans=min(ans,abs(snuke-(card-snuke)))
print(ans)

Failing test case input:
2
-64 1

Expected output:
65


Actual output:
63


Fixed submission (verdict: Accepted):






from sys import stdin,setrecursionlimit





setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
a=[int(i) for i in input().split()]
card=sum(a)
snuke=0
ans=10**10
for i in range(n-1):
    snuke+=a[i]
    ans=min(ans,abs(snuke-(card-snuke)))
print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,x=int(input()),0
s=list(map(int,input().split()))
for j in s:
    x+=j
x=x-s[0]*2
ans=x
for k in range(1,N-1):
    x=x-s[k]*2
    ans=min(ans,abs(x))
print(ans)    
    

Failing test case input:
2
-1 -30

Expected output:
29


Actual output:
-29


Fixed submission (verdict: Accepted):
N,x=int(input()),0
s=list(map(int,input().split()))
for j in s:
    x+=j
x=x-s[0]*2
ans=abs(x)
for k in range(1,N-1):
    x=x-s[k]*2
    ans=min(ans,abs(x))
print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
a=list(map(int,input().split()))
a.sort();
ans = int(0)
arai = int(0)
now = int(0)
mini = int(1000000001)
for i in range(N):
	ans+=a[i]
for i in range(N-1):
	now+=a[i]
	arai=ans-now
	mini=min(mini,abs(now-arai))

print(mini)

Failing test case input:
6
1 30 1 10 -1 6

Expected output:
15


Actual output:
13


Fixed submission (verdict: Accepted):
N=int(input())
a=list(map(int,input().split()))
sum = int(0)
arai = int(0)
ans = int(0)
mini = float('inf')

for i in range(N):
	sum+=a[i]
for i in range(N-1):
	ans+=a[i]
	arai=sum-ans
	mini=min(mini,float(abs(ans-arai)))

print(int(mini))
Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = [int(i) for i in input().split()]


s = sum(a)
m = pow(10, 9)
b = a[0]
for i in range(1, N):
    b += a[i]
    c = s - b
    
    
    if m > (abs(b-c)):
        m = abs(b-c)

print(m)

Failing test case input:
2
-68 -1

Expected output:
67


Actual output:
69


Fixed submission (verdict: Accepted):
N = int(input())
a = [int(i) for i in input().split()]


s = sum(a)
m = pow(10, 20)
b = 0
for i in range(N-1):
    b += a[i]
    c = s - b
    
    
    if m > (abs(b-c)):
        m = abs(b-c)
    
print(m)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
a=[int(i) for i in input().split()]
X=0
Y=0
min=10**9+1
for i in range(N):
  X=X+a[i]

for j in range(N-1):
 for i in range(j):
  Y=Y+a[i]

  if abs(X-2*Y) <= min:
   min=abs(X-2*Y)
print(min)


Failing test case input:
2
-136 0

Expected output:
136


Actual output:
1000000001


Fixed submission (verdict: Accepted):
N=int(input())
a=[int(i) for i in input().split()]
X=0
Y=0
min=10**11
for i in range(N):
  X=X+a[i]

for j in range(N-1):
  Y=Y+a[j]
  if abs(X-2*Y) <= min:
   min=abs(X-2*Y)
print(min)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
SUM=sum(a)
sum_snuke = a[0]
sum_araisan = 0
answer = float('inf')

for i in range(n):
    sum_snuke += a[i]
    sum_araisan = SUM - sum_snuke
    
    if answer >= abs(sum_snuke - sum_araisan):
        answer = abs(sum_snuke - sum_araisan)

print(answer)

Failing test case input:
2
15 1

Expected output:
14


Actual output:
44


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
answer = float('inf')
araisan_sum = sum(a) - a[0]
snuke_sum = a[0]
if len(a) == 2:
    answer = abs(snuke_sum - araisan_sum)
else:
    for i in range(1, n-1):
        snuke_sum += a[i]
        araisan_sum -= a[i]
        if answer >= abs(snuke_sum - araisan_sum):
            answer = abs(snuke_sum - araisan_sum)

print(answer)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
a=list(map(int,input().split()))
S=sum(a[1:])
SS=a[0]
mi=abs(S-SS)
for i in range(1,N-1):
    if mi>=abs(S-SS-2*a[i]):
        S=S-a[i]
        SS=SS+a[i]
        mi=abs(S-SS)
print(mi)


Failing test case input:
6
1 36 1 10 -1 1

Expected output:
26


Actual output:
24


Fixed submission (verdict: Accepted):
N=int(input())
a=list(map(int,input().split()))
S=sum(a)
SS=0
mi=1000000000000000
for i in range(N-1):
    S=S-a[i]
    SS=SS+a[i]
    if mi>=abs(S-SS):
        mi=abs(S-SS)
print(mi)
Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    N = int(input())
    A = sorted(list(map(int, input().split())), reverse=True)
    x = A[0]
    y = A[1]
    for i in range(2, N):
        if x > y:
            y += A[i]
        else:
            x += A[i]
    print(abs(x - y))


main()


Failing test case input:
6
-1 15 3 3 1 4

Expected output:
3


Actual output:
5


Fixed submission (verdict: Accepted):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = A[0]
    y = sum(A[1:])
    ans = abs(x - y)
    for i in range(1, N - 1):
        x += A[i]
        y -= A[i]
        ans = min(ans, abs(x - y))
    print(ans)


main()

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))
L=[0]*(N+1)
ans=99999
S=sum(A)
for i in range(N):
  L[i+1]=L[i]+A[i]
print(L)
for i in range(1,N):
  x = L[i]
  y = S - L[i]
  if ans >= abs(x-y):
    ans = abs(x-y)
print(ans)

Failing test case input:
6
1 36 1 10 -1 6

Expected output:
21


Actual output:
[0, 1, 37, 38, 48, 47, 53]
21


Fixed submission (verdict: Accepted):
import sys

N=int(input())
A=list(map(int,input().split()))
L=[0]*(N+1)
ans=sys.maxsize

for i in range(N):
  L[i+1]=L[i]+A[i]

for i in range(1,N):
  x = L[i]
  y = L[-1] - L[i]
  if ans >= abs(x-y):
    ans = abs(x-y)
print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def mainC():
    
    N = int(input())
    a = list(map(int, input().split()))
    s = sum(a)
    m = float('inf')
    d2 = a[0]
    for i in range(1, N-1):
        d2 += a[i]
        m = min( m, abs(s-2*d2) )
    print( m ) 

mainC()

Failing test case input:
2
44 -3

Expected output:
47


Actual output:
inf


Fixed submission (verdict: Accepted):
def mainC():
    
    N = int(input())
    a = list(map(int, input().split()))
    s = sum(a)
    d2 = a[0]
    m = abs(s-2*d2)
    for i in range(1, N-1):
        d2 += a[i]
        m = min( m, abs(s-2*d2) )
    print( m )

mainC()

Problem: p03659
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a_lst = list(map(int, input().split()))

x = 0
y = sum(a_lst)
diff = y
for a in a_lst:
  x += a
  y -= a
  diff = min(diff, abs(y - x))
print(diff)

Failing test case input:
2
-1 -89

Expected output:
88


Actual output:
-90


Fixed submission (verdict: Accepted):
n = int(input())
a_lst = list(map(int, input().split()))

x = a_lst[0]
y = sum(a_lst[1:])
diff = abs(y - x)
for a in a_lst[1:-1]:
  x += a
  y -= a
  diff = min(diff, abs(y - x))
print(diff)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = sorted(map(int, input().split()))

sum_v = sum(a)
min_v = 10**10
x = 0
for i in range(0,N-1):
    x += a[i]
    y = sum_v - x 
    
    min_v = min(min_v, abs(x-y))
print(min_v)


Failing test case input:
6
1 36 1 10 -1 6

Expected output:
21


Actual output:
19


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int, input().split()))

sum_v = sum(a)
min_v = 10**10
x = 0
for i in range(0,N-1):
    x += a[i]
    y = sum_v - x 
    
    min_v = min(min_v, abs(x-y))
print(min_v)
Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

ans = float('inf')
s = sum(A)
x = A[0]

for i in range(1, N-1):
    x += A[i]
    y = s - x
    d = abs(x-y)
    ans = min(ans, d)

print(ans)


Failing test case input:
2
-42 2

Expected output:
44


Actual output:
inf


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

ans = float('inf')
s = sum(A)
x = A[0]
y = s - x
d = abs(x-y)
ans = min(ans, d)

for i in range(1, N-1):
    x += A[i]
    y = s - x
    d = abs(x-y)
    ans = min(ans, d)

print(ans)

Problem: p03659
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n= int(input())
a = list(map(int,input().split()))

ls = []
ls.append(a[0])

for i in range(1,n):
    ls.append(a[i]+a[i-1])

Sum = ls[-1]
ans = 10**9
for i in range(0,n-1):
    ans = min(abs(Sum-2*ls[i]),ans)

print(ans)

Failing test case input:
6
1 36 1 10 -1 1

Expected output:
26


Actual output:
2


Fixed submission (verdict: Accepted):
n= int(input())
a = list(map(int,input().split()))

ls = []
ls.append(a[0])

for i in range(1,n):
    ls.append(a[i]+ls[i-1])

Sum = ls[-1]
ans = 10**20
for i in range(0,n-1):
    ans = min(abs(Sum-2*ls[i]),ans)

print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = list(map(int,input().split()))

x = a[0]
y = sum(a[1:])

ans = abs(x-y)

for i in range(N-1):
    x += a[i+1]
    y -= a[i+1]
    ans = min(ans, abs(x-y))

print(ans)

Failing test case input:
2
-108 2

Expected output:
110


Actual output:
106


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int,input().split()))

s = sum(a)
l = 0

ans = 10**10
   
for i in range(N-1):
    l += a[i]
    ans = min(ans, abs(s - 2*l))

print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
input_list = [int(i) for i in input().split()]

index = 1
ruiseki_list = [0]*(N+1)
result = 10*9

if N == 2:
    print(abs(input_list[0]-input_list[1]))
else:
    for i in input_list:
        ruiseki_list[index] = ruiseki_list[index-1] + i
        index += 1

    mapped_list = map(lambda x: ruiseki_list[N]-x, ruiseki_list)
    result_list = [abs(a-b) for (a, b) in zip(mapped_list, ruiseki_list)]
    print(result_list)
    print(min(result_list[2:N]))

Failing test case input:
6
0 2 3 7 5 6

Expected output:
1


Actual output:
[23, 23, 19, 13, 1, 11, 23]
1


Fixed submission (verdict: Accepted):
N = int(input())
input_list = [int(i) for i in input().split()]

index = 1
ruiseki_list = [0]*(N+1)
result = 10*9

if N == 2:
    print(abs(input_list[0]-input_list[1]))
else:
    for i in input_list:
        ruiseki_list[index] = ruiseki_list[index-1] + i
        index += 1

    mapped_list = map(lambda x: ruiseki_list[N]-x, ruiseki_list)
    result_list = [abs(a-b) for (a, b) in zip(ruiseki_list, mapped_list)]
    print(min(result_list[2:N]))
Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
A = list(map(int,input().split()))
A_sum = sum(A)
ans = 10**19
for i in range(n):
  x = A[:i+1]
  x_sum = sum(x)
  z = abs(A_sum - 2*x_sum)
  ans = min(ans,z)
print(ans)


Failing test case input:
2
-25 5

Expected output:
30


Actual output:
20


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
sum_A = sum(A)
ans = 10**20
X = 0
for a in A[:-1]:
    X += a
    ans = min(ans,abs(sum_A-2*X))
print(ans)

Problem: p03659
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):


import math
N = int(input())
lst = list(map(int,input().split()))
ans = float('inf')
x = lst[0]
y = sum(lst[1:])

for i in range(1,N-1):
    x+=lst[i]
    y-=lst[i]
    ans = min(ans,abs(x-y))
print(ans)

Failing test case input:
2
-108 2

Expected output:
110


Actual output:
inf


Fixed submission (verdict: Accepted):


import math
N = int(input())
lst = list(map(int,input().split()))
x = lst[0]
y = sum(lst[1:])
ans = abs(y - x)
for i in range(1,N-1):
    x+=lst[i]
    y-=lst[i]
    ans = min(ans,abs(x-y))
print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = [int(item) for item in input().split()]

sunuke = sum(a)
raccoon = 0
minimum = abs(sunuke - raccoon)
for i in a:
    sunuke -= i
    raccoon += i
    if(abs(sunuke - raccoon) > minimum):
        break
    minimum = abs(sunuke - raccoon)
print(minimum)

Failing test case input:
2
-25 5

Expected output:
30


Actual output:
20


Fixed submission (verdict: Accepted):
N = int(input())
a = [int(item) for item in input().split()]

sunuke = sum(a[1:])
raccoon = a[0]
minimum = abs(sunuke - raccoon)
for i in range(1, N):
    if(abs(sunuke - raccoon) < minimum):
        minimum = abs(sunuke - raccoon)
    sunuke -= a[i]
    raccoon += a[i]
       
print(minimum)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,x,ans=int(input()),0,10**18
s=list(map(int,input().split()))
for j in s:
    x+=j
x=x-s[0]*2
for k in range(1,N-1):
    x=abs(x-s[k]*2)
    ans=min(ans,x)
print(ans)    
    

Failing test case input:
2
-85 1

Expected output:
86


Actual output:
1000000000000000000


Fixed submission (verdict: Accepted):
N,x=int(input()),0
s=list(map(int,input().split()))
for j in s:
    x+=j
x=x-s[0]*2
ans=abs(x)
for k in range(1,N-1):
    x=x-s[k]*2
    ans=min(ans,abs(x))
print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

x = 0
y = sum(a)
ans = float("inf")
for i in range(n):
    x += a[i]
    y -= a[i]
    if i == 0 or i == n:
        ans = min(ans, abs(x - y))
print(ans)


Failing test case input:
6
0 3 3 7 1 8

Expected output:
4


Actual output:
22


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))

x = 0
y = sum(a)
ans = float("inf")
for i in range(n):
    x += a[i]
    y -= a[i]
    if not i == n - 1:
        ans = min(ans, abs(x - y))
print(ans)
Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N = int(input())
A = list(map(int, input().split()))
X = sum(A)
ans = 10 ** 6
x = 0
for i in range(N):
    x += A[i]
    if 0 < i < N-1:
        ans = min(ans, abs(X - 2 * x))
print(ans)

Failing test case input:
2
0 -20

Expected output:
20


Actual output:
1000000


Fixed submission (verdict: Accepted):

N = int(input())
A = list(map(int, input().split()))
X = sum(A)
ans = float("inf")
x = 0
for i in range(N):
    x += A[i]
    if i < N-1:
        ans = min(ans, abs(X - 2 * x))
print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools

n = int(input())
a = list(map(int,input().split()))

s = sum(a)
ac = list(itertools.accumulate(a))

ans = 10**9
for i in range(n):
  ans = min(ans,abs(s-ac[i]*2))
print(ans)  

Failing test case input:
2
-69 3

Expected output:
72


Actual output:
66


Fixed submission (verdict: Accepted):
import itertools

n = int(input())
a = list(map(int,input().split()))

s = sum(a)
ac = list(itertools.accumulate(a))


ans = 10**20

for i in range(n-1):
  ans = min(ans,abs(ac[i]*2-s))
  
print(ans)

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

def solve():
    ans = float("inf")
    araiguma = sum(A)
    snuke = 0
    for A_i in A:
        snuke += A_i
        araiguma -= A_i
        score = araiguma - snuke
        if score < ans:
            ans = score
    print(ans)


solve()

Failing test case input:
6
1 36 1 10 -1 1

Expected output:
26


Actual output:
-48


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

def solve():
    ans = float("inf")
    araiguma = sum(A)
    snuke = 0
    for A_i in A[0:-1]:
        snuke += A_i
        araiguma -= A_i
        score = abs(araiguma - snuke)
        if score < ans:
            ans = score
    print(ans)


solve()

Problem: p03659
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))


s = sum(a)
subsum = 0
res = 1001001001001001
for i in range(n-1):
    subsum += a[i]
    remain = s - subsum
    print(subsum, remain)
    res = min(res, abs(remain-subsum))

print(res)

Failing test case input:
2
-66 3

Expected output:
69


Actual output:
-66 3
69


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))


s = sum(a)
subsum = 0
res = 1001001001001001
for i in range(n-1):
    subsum += a[i]
    remain = s - subsum
    res = min(res, abs(remain-subsum))

print(res)