#include <bits/stdc++.h>
using namespace std;
long long arr[200010];
long long front[200010];
long long back[200010];
int G_LOWERBOUND(long long a[], int l, int r, long long val) {
  int mid;
  while (l < r) {
    mid = l + (r - l) / 2;
    if (a[mid] <= val)
      l = mid + 1;
    else
      r = mid;
  }
  return l;
}
int GE_LOWERBOUDN_RTOL(long long a[], int l, int r, long long val) {
  int mid;
  while (l < r) {
    mid = r - (r - l) / 2;
    if (a[mid] < val)
      r = mid - 1;
    else
      l = mid;
  }
  return r;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  front[0] = 0;
  for (int i = 1; i <= n; i++) front[i] = front[i - 1] + arr[i];
  back[n + 1] = 0;
  for (int i = n; i >= 1; i--) back[i] = back[i + 1] + arr[i];
  int A;
  int B;
  A = G_LOWERBOUND(front, 1, n + 1, front[n] / 2) - 1;
  for (; A >= 0; A--) {
    B = GE_LOWERBOUDN_RTOL(back, A, n + 1, front[A]);
    if (back[B] == front[A]) break;
  }
  cout << front[A] << endl;
  return 0;
}
