#include <bits/stdc++.h>
using namespace std;
int arr[1000000];
long long ltor[1000000];
long long rtol[1000000];
bool bin_search(long long x, int l, int r) {
  int mid = (l + r) / 2;
  if (x == rtol[mid]) return true;
  if (l == r) return false;
  if (x < rtol[mid])
    return bin_search(x, mid + 1, r);
  else
    return bin_search(x, l, mid);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    ltor[i] = (i != 0) ? ltor[i - 1] + arr[i] : arr[i];
  }
  for (int i = n - 1; i > -1; i--)
    rtol[i] = (i != n - 1) ? rtol[i + 1] + arr[i] : arr[i];
  long long ans = 0;
  for (int i = 0; i < n - 1; i++) {
    if (bin_search(ltor[i], i + 1, n - 1)) ans = max(ans, ltor[i]);
  }
  cout << ans;
  return 0;
}
