#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long, long long> i, pair<long long, long long> j) {
  return i.first > j.first;
}
int main() {
  long long n, k;
  cin >> n;
  vector<long long> A(n);
  for (long long i = 0; i < n; i++) {
    cin >> A[i];
  }
  long long sum1 = 0, sum3 = 0, count = 0;
  long long l = -1, r = n;
  long long ans1 = -1;
  while (count != n) {
    if (sum1 < sum3) {
      l++;
      count++;
      sum1 += A[l];
      continue;
    }
    if (sum1 > sum3) {
      r--;
      count++;
      sum3 += A[r];
      continue;
    }
    if (sum1 == sum3) {
      ans1 = sum1;
      l++;
      sum1 += A[l];
      count++;
      continue;
    }
  }
  if (sum1 == sum3) {
    ans1 = sum1;
  }
  cout << ans1;
  return 0;
}
