#include <bits/stdc++.h>
using namespace std;
const int N = 4005, M = 39999983;
int n, a[N], dp[M + 5];
int Hash(int x1, int x2, int x3, int x4) {
  return ((((4000ll * x1 + x2) * 91ll + x3) * 2ll) + x4) % M;
}
int dfs(int l, int r, int k, int op) {
  if (r - l + 1 < k) return 0;
  if (r - l + 1 == k) return (a[r] - a[l - 1]) * (op ? -1 : 1);
  int hh = Hash(l, r, k, op);
  if (dp[hh] != -1) return dp[hh];
  if (!op) {
    int sum = dfs(l + k, r, k, 1) + a[l + k - 1] - a[l - 1];
    if (l + k <= r)
      sum = max(sum, dfs(l + k + 1, r, k + 1, 1) + a[l + k] - a[l - 1]);
    return dp[hh] = sum;
  }
  int sum = dfs(l, r - k, k, 0) - a[r] + a[r - k];
  if (l <= r - k)
    sum = min(sum, dfs(l, r - k - 1, k + 1, 0) - a[r] + a[r - k - 1]);
  return dp[hh] = sum;
}
int main() {
  scanf("%d", &n);
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] += a[i - 1];
  }
  printf("%d", dfs(1, n, 1, 0));
  return 0;
}
