#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int A[n];
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  long long int i = 0, j = n - 1;
  long long int maxsum = 0;
  long long int sum1 = 0, sum2 = 0;
  while (i <= j) {
    if (sum1 < sum2) {
      sum1 += A[i];
      i++;
    } else if (sum1 == sum2) {
      if (i == j) break;
      maxsum = sum1;
      sum1 += A[i];
      sum2 += A[j];
      i++;
      j--;
    } else {
      sum2 += A[j];
      j--;
    }
  }
  if (sum1 == sum2) {
    maxsum = sum1;
  }
  cout << maxsum << endl;
  return 0;
}
