#include <bits/stdc++.h>
using namespace std;
int n, m, k;
pair<long long, long long> song[300004];
long long pre[300004];
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  ;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> pre[i];
  long long s1 = 0, s2 = 0;
  long long odp = 0;
  int in = 1, in2 = n;
  if (n == 1) {
    cout << "0\n";
    return;
  }
  while (in - 1 < in2 + 1) {
    while (in - 1 < in2 && s1 < s2) {
      s1 += pre[in];
      in++;
    }
    while (in - 1 < in2 && s1 > s2) {
      s2 += pre[in2];
      in2--;
    }
    if (s1 == s2) odp = s1;
    s1 += pre[in];
    ++in;
  }
  cout << odp << "\n";
}
int main() { init(); }
