#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, ans = 0, j;
  cin >> n;
  vector<long long> v(n), f(n + 1, 0), b(n + 1, 0);
  for (i = 0; i < n; i++) cin >> v[i];
  for (i = 1; i < n + 1; i++) {
    f[i] = v[i - 1] + f[i - 1];
    b[n - i] = v[n - i] + b[n + 1 - i];
  }
  f.erase(f.begin());
  b.pop_back();
  sort(b.begin(), b.end());
  for (i = 0, j = 0; i + j <= n - 2 && i < n && j < n;) {
    if (f[i] < b[j]) i++;
    if (b[j] < f[i]) j++;
    if (b[j] == f[i]) {
      ans = b[j];
      i++, j++;
    }
  }
  cout << ans;
  return 0;
}
