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