#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4002;
const int INFTY = 1 << 30;
int N;
int A[MAXN];
int pre[MAXN];
int dp[MAXN][100][100];
int getdp(int left, int dif, int k) {
  if (dp[left][dif][k] != -INFTY) return dp[left][dif][k];
  int right = N - left + 1 - dif;
  if (left + k - 1 <= right) {
    int mindp = INFTY;
    if (left + k - 1 < right - k + 1)
      mindp =
          min(mindp, -(pre[right] - pre[right - k]) + getdp(left + k, dif, k));
    if (left + k - 1 < right - k)
      mindp = min(mindp, -(pre[right] - pre[right - k - 1]) +
                             getdp(left + k, dif + 1, k + 1));
    if (mindp == INFTY) mindp = 0;
    dp[left][dif][k] =
        max(dp[left][dif][k], pre[left + k - 1] - pre[left - 1] + mindp);
  }
  if (left + k <= right) {
    int mindp = INFTY;
    if (left + k < right - k)
      mindp = min(mindp, -(pre[right] - pre[right - k - 1]) +
                             getdp(left + k + 1, dif, k + 1));
    if (left + k < right - k - 1)
      mindp = min(mindp, -(pre[right] - pre[right - k - 2]) +
                             getdp(left + k + 1, dif + 1, k + 2));
    if (mindp == INFTY) mindp = min(mindp, 0);
    dp[left][dif][k] =
        max(dp[left][dif][k], pre[left + k] - pre[left - 1] + mindp);
  }
  if (dp[left][dif][k] == -INFTY) dp[left][dif][k] = 0;
  return dp[left][dif][k];
}
int main() {
  ios::sync_with_stdio(0);
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    pre[i] = pre[i - 1] + A[i];
  }
  for (int i = 0; i < MAXN; i++)
    for (int j = 0; j < 100; j++)
      for (int k = 0; k < 100; k++) dp[i][j][k] = -INFTY;
  cout << getdp(1, 0, 1) << "\n";
  return 0;
}
