#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<pair<ll, ll> > l;
  ll sum = 0;
  l.push_back({0, 0});
  for (int i = 0; i < n; i++) {
    sum += a[i];
    l.push_back({sum, i + 1});
  }
  sum = 0;
  set<ll> s;
  map<ll, ll> m;
  int cnt = 1;
  for (int i = n - 1; i >= 0; i--) {
    sum += a[i];
    m[sum] = cnt;
    s.insert(sum);
    cnt++;
  }
  sort(l.rbegin(), l.rend());
  for (int i = 0; i < n; i++) {
    if (s.count(l[i].first)) {
      if (l[i].second + m[l[i].first] <= n) {
        cout << l[i].first;
        return 0;
      }
    }
  }
  cout << 0;
  return 0;
}
