#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1E9;
const double INFD = 1E9;
const long long INFLL = (long long)1E15;
const long long MOD = (long long)1E9 + 7;
const long double PI = acos(-1);
const long double EPS = 1E-9;
bool between(int x, int l, int r) { return (l <= x && x <= r); }
string tostring(int x) {
  char dum[20];
  sprintf(dum, "%d", x);
  string ret(dum);
  return ret;
}
inline void work(int kasus) {}
int n;
long long A[200010];
map<long long, int> S;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i += 1) scanf("%lld", A + i);
  long long sum = 0;
  S[0] = -1;
  for (int i = 0; i < n; i += 1) {
    sum += A[i];
    S[sum] = i;
  }
  long long ans = 0;
  sum = 0;
  for (int i = n - 1; i >= 0; i--) {
    sum += A[i];
    if (!S.count(sum)) continue;
    if (i > S[sum]) ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
