N = int(input())
weight = list(map(int, input().strip().split()))
 
S1 = 0
S2 = 0
 
for i in range(N):
    S1 += weight[i]
 
res = S1
for i in range(N):
    S1 -= weight[i]
    S2 += weight[i]
    if S1 < S2:
        if S2 - S1 < res:
            res = S2 - S1
        break
    if S1 - S2 < res:
        res = S1 - S2
 
print(res) N = int(input()) N int(input()) int input() input weight = list(map(int, input().strip().split())) weight list(map(int, input().strip().split())) list map(int, input().strip().split()) map int input().strip().split() ().strip().split ().strip() ().strip () input strip split S1 = 0 S1 0 S2 = 0 S2 0 for i in range(N):
    S1 += weight[i]
  i range(N) range N S1 += weight[i] S1 weight[i] weight i res = S1 res S1 for i in range(N):
    S1 -= weight[i]
    S2 += weight[i]
    if S1 < S2:
        if S2 - S1 < res:
            res = S2 - S1
        break
    if S1 - S2 < res:
        res = S1 - S2
  i range(N) range N S1 -= weight[i] S1 weight[i] weight i S2 += weight[i] S2 weight[i] weight i if S1 < S2:
        if S2 - S1 < res:
            res = S2 - S1
        break
     S1 < S2 S1 S2 if S2 - S1 < res:
            res = S2 - S1
         S2 - S1 < res S2 - S1 S2 S1 res res = S2 - S1 res S2 - S1 S2 S1 break if S1 - S2 < res:
        res = S1 - S2
  S1 - S2 < res S1 - S2 S1 S2 res res = S1 - S2 res S1 - S2 S1 S2 print(res) print res S1 += weight[i] weight[i] S1 S2 = 0 0 S2 res = S1 - S2 S1 - S2 res S1 -= weight[i] weight[i] S1 res = S2 - S1 S2 - S1 res N = int(input()) int(input()) N S2 += weight[i] weight[i] S2 weight = list(map(int, input().strip().split())) list(map(int, input().strip().split())) weight S1 = 0 0 S1 res = S1 S1 res
N = int(input())
weight = list(map(int, input().strip().split()))
 
S1 = 0
S2 = 0
 
for i in range(N):
    S1 += weight[i]
 
res = S1
for i in range(N):
    S1 -= weight[i]
    S2 += weight[i]
    if S1 < S2:
        if S2 - S1 < res:
            res = S2 - S1
        break
    if S1 - S2 < res:
        res = S1 - S2
 
print(res)