#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
long long dp[200105], dp2[200105];
long long a[200105];
const int MN = (1 << 19) + 5;
struct mb {
  int M;
  long long T[MN];
  void init(int sz) {
    for (M = 1; sz + 2 > M; M <<= 1)
      ;
    for (int(i) = 0; (i) < (int)(MN); (i)++) T[i] = -(1LL << 60);
  }
  void clear() { memset(T, 0, sizeof T); }
  void upt(int l, long long val) {
    l += M;
    T[l] = max(T[l], val);
    while (l > 1) {
      T[l >> 1] = max(T[l], T[l ^ 1]);
      l >>= 1;
    }
  }
  long long qy(int l, int r) {
    long long ans = -(1LL << 60);
    for (l = l + M - 1, r = r + M + 1; l ^ r ^ 1; l >>= 1, r >>= 1) {
      if (~l & 1) ans = max(ans, T[l ^ 1]);
      if (r & 1) ans = max(ans, T[r ^ 1]);
    }
    return ans;
  }
} tr;
struct mb1 {
  int M;
  long long T[MN];
  void init(int sz) {
    for (M = 1; sz + 2 > M; M <<= 1)
      ;
    for (int(i) = 0; (i) < (int)(MN); (i)++) T[i] = (1LL << 60);
  }
  void clear() { memset(T, 0, sizeof T); }
  void upt(int l, long long val) {
    l += M;
    T[l] = min(T[l], val);
    while (l > 1) {
      T[l >> 1] = min(T[l], T[l ^ 1]);
      l >>= 1;
    }
  }
  long long qy(int l, int r) {
    long long ans = (1LL << 60);
    for (l = l + M - 1, r = r + M + 1; l ^ r ^ 1; l >>= 1, r >>= 1) {
      if (~l & 1) ans = min(ans, T[l ^ 1]);
      if (r & 1) ans = min(ans, T[r ^ 1]);
    }
    return ans;
  }
} tr1;
void fmain() {
  scanf("%d", &n);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    scanf("%lld", a + i);
    a[i] += a[i - 1];
  }
  dp[n - 1] = a[n];
  dp2[n - 1] = -a[n];
  tr.init(n);
  tr.upt(n - 1, dp2[n - 1] + a[n - 1]);
  tr1.init(n);
  tr1.upt(n - 1, dp[n - 1] - a[n - 1]);
  for (int i = n - 2; i; i--) {
    dp[i] = tr.qy(i + 1, n - 1);
    dp[i] = max(dp[i], a[n]);
    dp2[i] = tr1.qy(i + 1, n - 1);
    dp2[i] = min(dp2[i], -a[n]);
    tr.upt(i, dp2[i] + a[i]);
    tr1.upt(i, dp[i] - a[i]);
  }
  printf("%lld\n", dp[1]);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain();
  }
  return 0;
}
