#include <bits/stdc++.h>
const int M = 1e9 + 7;
using namespace std;
long long power(long long a, long long b) {
  int result = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      result *= a;
    }
    a *= a;
    b /= 2;
  }
  return result;
}
long long gcd(long long x, long long y) {
  long long r;
  while (y != 0 && (r = x % y) != 0) {
    x = y;
    y = r;
  }
  return y == 0 ? x : y;
}
long long countSetBits(long long x) {
  long long Count = 0;
  while (x > 0) {
    if (x & 1) Count++;
    x = x >> 1;
  }
  return Count;
}
bool isPerfectSquare(long long n) {
  long long sr = sqrt(n);
  if (sr * sr == n)
    return true;
  else
    return false;
}
long long mod(long long x) { return ((x % M + M) % M); }
long long add(long long a, long long b) { return mod(mod(a) + mod(b)); }
long long mul(long long a, long long b) { return mod(mod(a) * mod(b)); }
long long powerM(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b % 2 == 1) {
      res = mul(a, res);
    }
    a = mul(a, a);
    b /= 2;
  }
  return res;
}
vector<bool> sieve_of_eratothenes(long long n) {
  vector<bool> a(n + 1, 1);
  a[0] = 0;
  a[1] = 0;
  for (long long i = 2; i <= sqrt(n); i++) {
    if (a[i] == 1) {
      for (long long j = 2; i * j <= n; j++) {
        a[j * i] = 0;
      }
    }
  }
  return a;
}
long long modInverse(long long n) { return powerM(n, M - 2); }
long long nCrM(long long n, long long r) {
  if (n < r) return 0;
  if (r == 0) return 1;
  vector<long long> fact(n + 1);
  fact[0] = 1;
  for (long long i = 1; i <= n; i++) {
    fact[i] = mul(fact[i - 1], i);
  }
  return mul(mul(fact[n], modInverse(fact[r])), modInverse(fact[n - r]));
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) cin >> v[i];
  map<long long, long long> psum;
  map<long long, long long> ssum;
  long long a = 0;
  for (long long i = 0; i < n; i++) {
    a += v[i];
    if (psum[a] == 0) {
      psum[a] = i + 1;
    }
  }
  reverse(v.begin(), v.end());
  a = 0;
  for (long long i = 0; i < n; i++) {
    a += v[i];
    if (ssum[a] == 0) {
      ssum[a] = n - i;
    }
  }
  long long ans = 0;
  for (auto it = psum.begin(); it != psum.end(); it++) {
    if (ssum[it->first] > it->second) {
      ans = max(ans, it->first);
    }
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  solve();
  return 0;
}
