#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n;
long long a[N], sum, ans;
set<long long> setik;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    sum += a[i];
    setik.insert(sum);
  }
  long long s = sum, sum = 0;
  for (int i = n; i >= 1; --i) {
    sum += a[i];
    setik.erase(s);
    s -= a[i];
    if (setik.find(sum) != setik.end()) ans = max(ans, sum);
  }
  cout << ans;
}
