#include <bits/stdc++.h>
using namespace std;

int main() {
  long long N,ans=202020202020;
  cin >> N;
  vector<long long> A(N);
  cin >> A[0];
  for(int i=1;i<N;i++){
    cin >> A[i];
    A[i] += A[i-1];
  }
  
  for(int i=0;i<N-1;i++){
    long long x = A[i] , y = A[N-1]-A[i];
    ans = min(ans,abs(x-y));
  }
  
  cout << ans << endl;
  return 0;
}
