N = int(input())
ls1 = list(map(int, input().split()))

a=0
al1=sum(ls1)
b=al1

for i in range(len(ls1)):
    c1=abs(a-b)
    a=sum(ls1[:i+1])
    b=al1-a
    c2=abs(a-b)
    if c1<c2:
        print(c1)
        break N = int(input()) N int(input()) int input() input ls1 = list(map(int, input().split())) ls1 list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split a=0 a 0 al1=sum(ls1) al1 sum(ls1) sum ls1 b=al1 b al1 for i in range(len(ls1)):
    c1=abs(a-b)
    a=sum(ls1[:i+1])
    b=al1-a
    c2=abs(a-b)
    if c1<c2:
        print(c1)
        break i range(len(ls1)) range len(ls1) len ls1 c1=abs(a-b) c1 abs(a-b) abs a-b a b a=sum(ls1[:i+1]) a sum(ls1[:i+1]) sum ls1[:i+1] ls1 :i+1 i+1 i 1 b=al1-a b al1-a al1 a c2=abs(a-b) c2 abs(a-b) abs a-b a b if c1<c2:
        print(c1)
        break c1<c2 c1 c2 print(c1) print c1 break a=sum(ls1[:i+1]) sum(ls1[:i+1]) a N = int(input()) int(input()) N c2=abs(a-b) abs(a-b) c2 ls1 = list(map(int, input().split())) list(map(int, input().split())) ls1 b=al1 al1 b al1=sum(ls1) sum(ls1) al1 a=0 0 a b=al1-a al1-a b c1=abs(a-b) abs(a-b) c1
N = int(input())
ls1 = list(map(int, input().split()))

a=0
al1=sum(ls1)
b=al1

for i in range(len(ls1)):
    c1=abs(a-b)
    a=sum(ls1[:i+1])
    b=al1-a
    c2=abs(a-b)
    if c1<c2:
        print(c1)
        break
