#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  deque<long> dq;
  long a;
  long long s1 = 0, s2 = 0, s3 = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    dq.push_back(a);
  }
  int l = dq.size();
  while (l > 0) {
    if (s1 == s2) {
      s3 = s1;
      s1 = s1 + dq.front();
      dq.pop_front();
      l--;
    }
    if ((s1 < s2) && (l > 0)) {
      s1 = s1 + dq.front();
      dq.pop_front();
      l--;
    }
    if ((s2 < s1) && (l > 0)) {
      s2 = s2 + dq.back();
      dq.pop_back();
      l--;
    }
    if (s1 == s2) {
      s3 = s1;
      s1 = s1 + dq.front();
      dq.pop_front();
      l--;
    }
    if (l == 0) break;
  }
  cout << s3 << endl;
  return 0;
}
