#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  long long total = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    total += a[i];
  }
  long long sum = 0;
  set<long long> s;
  for (long long i = 0; i < n; i++) {
    sum += a[i];
    if (total - sum >= sum) {
      s.insert(sum);
    }
  }
  sum = 0;
  long long mx = 0;
  for (long long i = n - 1; i >= 0; i--) {
    sum += a[i];
    if (s.find(sum) != s.end()) {
      mx = max(mx, sum);
    }
  }
  cout << mx;
}
