#include <bits/stdc++.h>
using namespace std;
static std::vector<int> C;
struct Key {
  short left, right, c;
  Key() {}
  Key(short left, short right, short c) : left(left), right(right), c(c) {}
  unsigned int hash() const { return 6287 * 6287 * left + 6287 * right + c; }
};
bool operator==(const Key& l, const Key& r) {
  return *(int*)&l == *(int*)&r && l.c == r.c;
}
struct Value {
  int r;
  Value(int r = -2147483648) : r(r){};
};
template <typename K, typename V, int N, int M = 2>
class MyHt {
 public:
  MyHt() { memset(data, 0, sizeof(data)); }
  V& operator[](const Key& k) {
    Unit** pp = &data[k.hash() % N];
    Unit* p = *pp;
    if (p == nullptr) {
      p = *pp = new Unit[M];
      p[0].k = k;
      p[1].k.left = -1;
      return p[0].v;
    } else {
      if (p[0].k == k) return p[0].v;
      if (!(p[1].k == k)) {
        p[1].k = k;
        p[1].v = Value();
      }
      return p[1].v;
    }
  }

 private:
  struct Unit {
    K k;
    V v;
  };
  Unit* data[N];
};
auto cache = new MyHt<Key, Value, 16 * 1024 * 1024>;
int solve(short l, short r, short c, short p) {
  const Key key(l, r, c);
  Value& ret = (*cache)[key];
  if (ret.r != -2147483648) return ret.r;
  if (p == 0) {
    l += c;
    if (l < r)
      return ret.r = max(solve(l, r, c, 1), solve(l + 1, r, c + 1, 1));
    else if (l == r)
      return ret.r = 2 * C[l];
    else
      return ret.r = C[l - c] + C[r];
  } else {
    r -= c;
    if (l < r)
      return ret.r = min(solve(l, r, c, 0), solve(l, r - 1, c + 1, 0));
    else if (l == r)
      return ret.r = 2 * C[l];
    else
      return ret.r = C[l] + C[r + c];
  }
}
int main(int argc, const char* argv[]) {
  int N;
  scanf("%d", &N);
  std::vector<int> A(N);
  for (auto&& a : A) scanf("%d", &a);
  C.resize(N + 1);
  for (int i = 0; i < N; i++) C[i + 1] = C[i] + A[i];
  printf("%d\n", solve(0, N, 1, 0) - C.back());
  return 0;
}
