#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
template <typename T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
T LCM(T a, T b) {
  return a * (b / gcd(a, b));
}
template <typename T, typename second>
T expo(T b, second e, const T &m) {
  if (e <= 1) return e == 0 ? 1 : b;
  return (e & 1) == 0 ? expo((b * b) % m, e >> 1, m)
                      : (b * expo((b * b) % m, e >> 1, m)) % m;
}
template <typename T, typename second>
T expo(T b, second e) {
  if (e <= 1) return e == 0 ? 1 : b;
  return (e & 1) == 0 ? expo((b * b), e >> 1) : (b * expo((b * b), e >> 1));
}
template <typename T, typename second>
T modinv(T a, second mod) {
  return expo(a, mod - 2, mod);
}
template <class T, class second>
std::ostream &operator<<(std::ostream &os, const std::pair<T, second> &t) {
  os << "(" << t.first << ", " << t.second << ")";
  return os;
}
template <class T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &t) {
  os << "[";
  for (__typeof(t.begin()) it = t.begin(); it != t.end(); it++) {
    if (it != t.begin()) os << ", ";
    os << *it;
  }
  os << "]";
  return os;
}
template <typename T>
void scanint(T &x) {
  T c = getchar();
  while (((c < 48) || (c > 57)) && (c != '-')) c = getchar();
  bool neg = false;
  if (c == '-') neg = true;
  x = 0;
  for (; c < 48 || c > 57; c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) x = (x * 10) + (c - 48);
  if (neg) x = -x;
}
const int MAXN = 2e5 + 3;
int n;
long long arr[MAXN], suff[MAXN];
long long pre[MAXN];
int corr_j[MAXN][2];
pair<long long, long long> dp[MAXN][2];
int main() {
  scanint(n);
  for (int i = 1; i <= n; i++) {
    scanint(arr[i]);
    pre[i] = pre[i - 1] + arr[i];
  }
  for (int i = n; i > 0; i--) suff[i] = suff[i + 1] + arr[i];
  int max_j[2] = {0};
  dp[n][0] = {0, 0}, dp[n][1] = {0, 0};
  max_j[0] = max_j[1] = n;
  for (int i = n - 1; i > 0; i--) {
    int j[2] = {max_j[0], max_j[1]};
    corr_j[i][0] = j[0];
    corr_j[i][1] = j[1];
    dp[i][0].first = pre[j[0]] + dp[j[0]][1].second;
    dp[i][0].second = dp[j[0]][1].first;
    dp[i][1].first = pre[j[1]] + dp[j[1]][0].second;
    dp[i][1].second = dp[j[1]][0].first;
    if (pre[j[0]] + dp[j[0]][1].second - dp[j[0]][1].first <
        pre[i] + dp[i][1].second - dp[i][1].first) {
      max_j[0] = i;
    }
    if (pre[j[1]] + dp[j[1]][0].second - dp[j[1]][0].first <
        pre[i] + dp[i][0].second - dp[i][0].first) {
      max_j[1] = i;
    }
  }
  long long cost[2] = {0, 0};
  int curr = 1, turn = 0;
  while (curr < n) {
    cost[turn] += pre[corr_j[curr][turn]];
    curr = corr_j[curr][turn];
    turn ^= 1;
  }
  printf("%I64d\n", cost[0] - cost[1]);
  return 0;
}
