#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  int T;
  T = 1;
  while (T--) {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    set<long long int> second;
    long long int sum = 0;
    for (int i = 0; i < n; i++) {
      sum += a[i];
      second.insert(sum);
    }
    long long int r = 0;
    long long int ans = 0;
    for (int i = n - 1; i >= 0; i--) {
      second.erase(sum);
      sum -= a[i];
      r += a[i];
      if (second.count(r) > 0) {
        ans = max(ans, r);
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
