#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int main() {
  int n;
  cin >> n;
  vector<int> g(n + 1);
  for (int i = 1; i <= n; i++) cin >> g[i];
  map<long long, int> mp;
  long long sum = 0;
  for (int i = n; i >= 1; i--) {
    sum += g[i];
    mp[sum] = i;
  }
  long long ans = 0, sum1 = 0;
  for (int i = 1; i <= n; i++) {
    sum1 += g[i];
    if (mp[sum1] > 0 && mp[sum1] > i) ans = max(sum1, ans);
  }
  cout << ans;
  return 0;
}
