#include <bits/stdc++.h>
using namespace std;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline long long int two(long long int n) { return 1 << n; }
inline long long int test(long long int n, long long int b) {
  return (n >> b) & 1;
}
inline void set_bit(long long int& n, long long int b) { n |= two(b); }
inline void unset_bit(long long int& n, long long int b) { n &= ~two(b); }
inline long long int last_bit(long long int n) { return n & (-n); }
inline long long int ones(long long int n) {
  long long int res = 0;
  while (n && ++res) n -= n & (-n);
  return res;
}
template <class T>
void chmax(T& a, const T& b) {
  a = max(a, b);
}
template <class T>
void chmin(T& a, const T& b) {
  a = min(a, b);
}
int main() {
  map<long long int, long long int> m;
  map<long long int, long long int>::iterator it;
  long long int n;
  cin >> n;
  long long int a[n];
  for (long long int i = 0; i < (n); i++) {
    cin >> a[i];
  }
  long long int sum = 0;
  for (long long int i = n - 1; i >= 0; i--) {
    sum += a[i];
    if (m.find(sum) == m.end()) m[sum] = i;
  }
  sum = 0;
  long long int flag = 0, ans = -1;
  for (long long int i = 0; i < (n); i++) {
    sum += a[i];
    if (m.find(sum) != m.end() && m[sum] > i) {
      ans = sum;
      flag = 1;
    }
  }
  if (flag)
    cout << ans << endl;
  else
    cout << 0 << endl;
  return 0;
}
