#include <bits/stdc++.h>
using namespace std;
class MinimizeAbsoluteDifferenceDiv2 {
 public:
  vector<int> findTriple(int a, int b, int c) {
    vector<int> d;
    long long min = 10000000;
    if (abs(a - b * c) < min) {
      d.clear();
      d.push_back(0);
      d.push_back(1);
      d.push_back(2);
      min = abs(a - b * c);
    }
    if (abs(b - c * a) < min) {
      d.clear();
      d.push_back(1);
      d.push_back(2);
      d.push_back(0);
      min = abs(b - c * a);
    }
    if (abs(c - a * b) < min) {
      d.clear();
      d.push_back(2);
      d.push_back(0);
      d.push_back(1);
      min = abs(c - a * b);
    }
    return d;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n;
  vector<long long> temps;
  long long tmp;
  for (long long i = 0; i < n; i++) {
    cin >> tmp;
    temps.push_back(tmp);
  }
  long long sum_l = 0, sum_r = 0;
  sum_l += temps[0];
  long long left_i = 1, right_i = n - 1;
  while (left_i <= right_i) {
    if (sum_l > sum_r) {
      sum_r += temps[right_i];
      right_i--;
    } else {
      sum_l += temps[left_i];
      left_i++;
    }
  }
  left_i--;
  right_i++;
  while (left_i != -1 && right_i != n) {
    if (sum_l == sum_r) {
      cout << sum_l;
      return 0;
    } else if (sum_l > sum_r) {
      sum_l -= temps[left_i];
      left_i--;
    } else {
      sum_r -= temps[right_i];
      right_i++;
    }
  }
  cout << 0;
  return 0;
}
