#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int arr[n];
  long long int i;
  for (i = 0; i < n; i++) cin >> arr[i];
  long long int pref[n];
  long long int suff[n];
  pref[0] = arr[0];
  suff[n - 1] = arr[n - 1];
  for (i = 1; i < n; i++) pref[i] = pref[i - 1] + arr[i];
  for (i = n - 2; i >= 0; i--) suff[i] = suff[i + 1] + arr[i];
  long long int ans = 0;
  for (i = 0; i < n; i++) {
    long long int val = pref[i];
    long long int low = i + 1;
    long long int high = n - 1;
    while (low <= high) {
      long long int mid = (low + high) / 2;
      if (suff[mid] > val)
        low = mid + 1;
      else if (suff[mid] < val)
        high = mid - 1;
      else {
        ans = val;
        break;
      }
    }
  }
  cout << ans;
}
