#include <bits/stdc++.h>
using namespace std;
const int N = 1000000;
long long dp[N][2], g[N][2], s[N], a[N];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  s[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    s[i] = s[i - 1] + a[i];
  }
  g[n][0] = g[n][1] = -s[n];
  for (int i = n - 1; i >= 1; i--) {
    dp[i][0] = -g[i + 1][1];
    dp[i][1] = -g[i + 1][0];
    g[i][0] = min(g[i + 1][0], dp[i][0] - s[i]);
    g[i][1] = min(g[i + 1][1], dp[i][1] - s[i]);
  }
  cout << dp[1][0] << "\n";
  return 0;
}
