#include <bits/stdc++.h>
int n;
long long num[200005], sum[200005], isum[200005];
long long max;
bool dfs(int loc, int pos) {
  if (isum[pos] == sum[loc]) {
    return true;
  }
  if (pos == loc || isum[pos] > sum[loc]) {
    return false;
  }
  return dfs(loc, pos - 1);
}
bool judge(int loc) {
  long long t1 = sum[loc];
  int low = n, high = loc;
  while (high <= low) {
    int mid = (low + high) / 2;
    long long t2 = isum[mid];
    if (t1 == t2) {
      return true;
    } else if (t1 > t2) {
      low = mid - 1;
    } else {
      high = mid + 1;
    }
  }
  return false;
}
int main() {
  while (scanf("%d", &n) != EOF) {
    sum[0] = num[0] = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &num[i]);
      sum[i] = sum[i - 1] + num[i];
    }
    isum[n] = 0;
    for (int i = n - 1; i >= 0; i--) {
      isum[i] = isum[i + 1] + num[i + 1];
    }
    max = -1;
    for (int i = n - 1; i >= 0; i--) {
      if (isum[i] >= sum[i]) {
        if (judge(i)) {
          max = sum[i];
          break;
        }
      }
    }
    printf("%lld\n", max);
  }
}
