# -*- coding: utf-8 -*-
import numpy as np
n = int(input())

cum = np.array(list(map(int, input().split()))).cumsum()
ans = cum[-1]
for i in range(n-1):
    ans = min(ans, abs(2*cum[i]-cum[-1]))
print(ans) import numpy as np numpy n = int(input()) n int(input()) int input() input cum = np.array(list(map(int, input().split()))).cumsum() cum np.array(list(map(int, input().split()))).cumsum() np.array(list(map(int, input().split()))).cumsum np.array(list(map(int, input().split()))) np.array np array list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split cumsum ans = cum[-1] ans cum[-1] cum -1 for i in range(n-1):
    ans = min(ans, abs(2*cum[i]-cum[-1])) i range(n-1) range n-1 n 1 ans = min(ans, abs(2*cum[i]-cum[-1])) ans min(ans, abs(2*cum[i]-cum[-1])) min ans abs(2*cum[i]-cum[-1]) abs 2*cum[i]-cum[-1] 2*cum[i] 2 cum[i] cum i cum[-1] cum -1 print(ans) print ans n = int(input()) int(input()) n ans = cum[-1] cum[-1] ans cum = np.array(list(map(int, input().split()))).cumsum() np.array(list(map(int, input().split()))).cumsum() cum ans = min(ans, abs(2*cum[i]-cum[-1])) min(ans, abs(2*cum[i]-cum[-1])) ans
# -*- coding: utf-8 -*-
import numpy as np
n = int(input())

cum = np.array(list(map(int, input().split()))).cumsum()
ans = cum[-1]
for i in range(n-1):
    ans = min(ans, abs(2*cum[i]-cum[-1]))
print(ans)
