#include <bits/stdc++.h>
using namespace std;
mt19937 rr;
const int inf = 1e9;
const int sz = 10000000;
unsigned ht[sz + 100000];
int hval[sz + 100000];
int hcnt;
const unsigned NONE = -1;
int& get(unsigned a, unsigned b, unsigned c, unsigned d) {
  unsigned x = 0;
  x = x + a;
  x = x * 4001 + b;
  x = x * 2 + c;
  x = x * 100 + d;
  unsigned h = (x >> 17) ^ (x * 10099) ^ ((x * 43) << 5);
  h %= sz;
  while (ht[h] != NONE && ht[h] != x) ++h;
  if (ht[h] == NONE) {
    ht[h] = x;
    hval[h] = inf;
    ++hcnt;
  }
  return hval[h];
}
int n;
int a[5050];
int s[5050];
void scan() {
  scanf("%d", &n);
  for (int i = 0; i < (int)(n); ++i) scanf("%d", &a[i]);
  for (int i = 0; i < (int)(n); ++i) s[i + 1] = s[i] + a[i];
}
int go(int l, int r, int par, int k) {
  if (r - l < k) return 0;
  int& res = get(l, r, par, k);
  if (res != inf) return res;
  if (par)
    res = inf;
  else
    res = -inf;
  for (int i = k; i <= k + 1; ++i)
    if (r - l >= i) {
      if (par == 0) {
        res = max(res, go(l + i, r, par ^ 1, i) + s[l + i] - s[l]);
      } else {
        res = min(res, go(l, r - i, par ^ 1, i) - s[r] + s[r - i]);
      }
    }
  return res;
}
int main() {
  memset(ht, -1, sizeof ht);
  scan();
  cout << go(0, n, 0, 1) << endl;
  return 0;
}
