#include <bits/stdc++.h>
#pragma GCC optimize "-O3"
using namespace std;
const char E = '\n';
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  unsigned long long n, a[200005], ans = 0, s1, s2, ii, jj;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  ii = 1;
  jj = n;
  s1 = a[ii];
  s2 = a[jj];
  for (int i = 1; i <= n; i++) {
    if (ii >= jj) break;
    if (s1 == s2) {
      ans += s1;
      ii++;
      jj--;
      s1 = a[ii];
      s2 = a[jj];
    }
    if (s1 < s2) {
      ii++;
      s1 += a[ii];
    } else if (s2 < s1) {
      jj--;
      s2 += a[jj];
    }
  }
  cout << ans << E;
  return 0;
}
