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

