#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma G++ optimize("O2")
using namespace std;
const int MOD = 1e7 + 7;
const int intINF = 1e9;
const long long llINF = 2e18;
int read() {
  int v = 0, f = 1;
  char c = getchar();
  while (c < 48 || 57 < c) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
  return v * f;
}
long long readll() {
  long long v = 0, f = 1;
  char c = getchar();
  while (c < 48 || 57 < c) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
  return v * f;
}
int dp[33333333];
int a[4444], s[4444], n, id;
void predo() {}
void init() {
  n = read();
  for (int i = (int)1; i <= (int)n; i++) a[i] = read();
}
inline int calc(int x, int y) { return s[y] - s[x - 1]; }
inline int getid(int a, int b, int c, int d) {
  return ((((a * 4444) + b) * 111 + c) * 2 + d) % 30000000;
}
int dfs(int i, int j, int k, int op) {
  int sta = getid(i, j, k, op);
  if (~dp[sta]) return dp[sta];
  if (j - i + 1 == k) {
    if (op == 0) return calc(i, j);
    return -calc(i, j);
  }
  if (j - i + 1 < k) return 0;
  int res;
  if (op == 0) {
    res = -intINF;
    if (i + k - 1 <= n)
      res = max(res, dfs(i + k, j, k, 1) + calc(i, i + k - 1));
    if (i + k <= n)
      res = max(res, dfs(i + k + 1, j, k + 1, 1) + calc(i, i + k));
  }
  if (op == 1) {
    res = intINF;
    if (j - k + 1 >= 1)
      res = min(res, dfs(i, j - k, k, 0) - calc(j - k + 1, j));
    if (j - k >= 1)
      res = min(res, dfs(i, j - k - 1, k + 1, 0) - calc(j - k, j));
  }
  dp[sta] = res;
  return res;
}
void solve() {
  memset(dp, -1, sizeof(dp));
  s[0] = 0;
  for (int i = (int)1; i <= (int)n; i++) s[i] = s[i - 1] + a[i];
  printf("%d\n", dfs(1, n, 1, 0));
}
int main() {
  predo();
  int cas = 1;
  while (cas--) {
    init();
    solve();
  }
  return 0;
}
