N = int(input())
List = list(map(int, input().split()))
S2 = 0
for i in range(N):
  S2 += List[i]
S1 =0 
res = S2
for i in range(N):
  S1 += List[i]
  S2 = S2 - List[i]
  res = min(abs(S2-S1),res)
print(res) N = int(input()) N int(input()) int input() input List = list(map(int, input().split())) List list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split S2 = 0 S2 0 for i in range(N):
  S2 += List[i] i range(N) range N S2 += List[i] S2 List[i] List i S1 =0 S1 0 res = S2 res S2 for i in range(N):
  S1 += List[i]
  S2 = S2 - List[i]
  res = min(abs(S2-S1),res) i range(N) range N S1 += List[i] S1 List[i] List i S2 = S2 - List[i] S2 S2 - List[i] S2 List[i] List i res = min(abs(S2-S1),res) res min(abs(S2-S1),res) min abs(S2-S1) abs S2-S1 S2 S1 res print(res) print res S1 =0 0 S1 res = min(abs(S2-S1),res) min(abs(S2-S1),res) res S2 = S2 - List[i] S2 - List[i] S2 N = int(input()) int(input()) N List = list(map(int, input().split())) list(map(int, input().split())) List S2 = 0 0 S2 S1 += List[i] List[i] S1 S2 += List[i] List[i] S2 res = S2 S2 res
N = int(input())
List = list(map(int, input().split()))
S2 = 0
for i in range(N):
  S2 += List[i]
S1 =0 
res = S2
for i in range(N):
  S1 += List[i]
  S2 = S2 - List[i]
  res = min(abs(S2-S1),res)
print(res)