#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int d[n + 2], ans = 0, i, mul = 0, k = 0;
  d[0] = 0;
  for (i = 1; i <= n; i++) {
    cin >> d[i];
  }
  long long int t = n, l = 0;
  while (t - l >= 0) {
    if (mul > 0)
      mul -= d[t], k += d[t], t--;
    else
      mul += d[l], l++;
    if (mul == 0) ans = max(ans, k);
  }
  cout << ans;
}
