#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<uint32_t> xs;
  xs.reserve(n);
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    xs.push_back(x);
  }
  vector<uint64_t> prefix_sum;
  prefix_sum.reserve(n);
  uint64_t current_sum = 0;
  for (auto x : xs) {
    current_sum += x;
    prefix_sum.push_back(current_sum);
  }
  vector<uint64_t> suffix_sum;
  suffix_sum.resize(n);
  current_sum = 0;
  for (int i = n - 1; i >= 0; --i) {
    current_sum += xs[i];
    suffix_sum[i] = current_sum;
  }
  uint64_t current_max = 0;
  for (int i = 0; i < n - 1; ++i) {
    auto target = prefix_sum[i];
    bool found =
        binary_search(suffix_sum.begin() + i + 1, suffix_sum.end(), target,
                      [](uint64_t a, uint64_t b) { return a > b; });
    if (found) {
      current_max = max(current_max, target);
    }
  }
  cout << current_max << endl;
}
