#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, k, l, m, n, p, t, r;
  cin >> n;
  vector<long long int> v(n);
  vector<long long int> pref(n);
  l = 0;
  vector<long long int> suff(n);
  for (i = 0; i < n; i++) {
    cin >> v[i];
    l += v[i];
    pref[i] = l;
  }
  l = 0;
  for (i = n - 1; i >= 0; i--) {
    l += v[i];
    suff[i] = l;
  }
  p = 0;
  for (i = 0; i < n; i++) {
    l = 0;
    r = n - 1;
    while (l <= r) {
      m = (l + r) / 2;
      if (pref[i] < suff[m]) {
        l = m + 1;
      } else if (pref[i] > suff[m]) {
        r = m - 1;
      } else {
        if (i < m) {
          p = max(p, pref[i]);
          break;
        } else if (i == m) {
          p = max(p, pref[i] - v[i]);
          break;
        } else
          break;
      }
    }
  }
  cout << p << "\n";
}
