#include <bits/stdc++.h>
using namespace std;
const int INF = 2000000000;
const double PI = acos(-1.0);
int solve(const vector<int>& a) {
  int n = a.size();
  vector<int> dp(a.size());
  vector<int> lsum(a.size());
  for (int i = 0; i < a.size(); i++) {
    lsum[i] = (i ? lsum[i - 1] : 0) + a[i];
  }
  vector<int> best(n);
  for (int i = a.size() - 1; i >= 0; --i) {
    dp[i] = lsum.back();
    if (i + 2 < a.size()) dp[i] = max(dp[i], best[i + 2]);
    if (i + 1 < a.size() && i != 0) dp[i] = max(dp[i], best[i + 1]);
    best[i] = (i ? lsum[i - 1] : 0) - dp[i];
    if (i + 1 < a.size()) best[i] = max(best[i], best[i + 1]);
  }
  return dp[0];
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  cout << solve(a) << endl;
  return 0;
}
