#include <bits/stdc++.h>
using namespace std;
map<long long, int> mp;
int main() {
  int n;
  cin >> n;
  long long a[n + 5], ls[n + 5], rs[n + 5];
  for (int i = 1; i <= n; i++) cin >> a[i];
  ls[0] = 0;
  for (int i = 1; i <= n; i++) {
    ls[i] = ls[i - 1] + a[i];
  }
  rs[n + 1] = 0;
  mp[0] = n + 1;
  for (int i = n; i >= 1; i--) {
    rs[i] = rs[i + 1] + a[i];
    mp[rs[i]] = i;
  }
  long long int ans = 0;
  for (int i = 0; i <= n; i++) {
    auto it = mp.find(ls[i]);
    if (it != mp.end()) {
      if (it->second > i) ans = max(ans, ls[i]);
    }
  }
  cout << ans << endl;
  return 0;
}
