#include <bits/stdc++.h>
int f[4001][4001], g[4001][4001], F[4001][4001], G[4001][4001], s[4001], N, U;
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%d", s + i), s[i] += s[i - 1];
  while (U * (U + 1) / 2 <= N) U++;
  for (int i = U; i; i--) {
    for (int j = N; ~j; j--) {
      for (int k = std::min(j + i - 1, N - j); k >= j; k--)
        if (j + k + i > N)
          F[j][k] = s[j] + s[N - k] - s[N];
        else if (j + k + i == N)
          F[j][k] = G[j + i][k];
        else
          F[j][k] = std::max(G[j + i][k], g[j + i + 1][k]);
      for (int k = std::min(j - 1, N - j); k >= j - i && k >= 0; k--)
        if (j + k + i > N)
          G[j][k] = s[j] + s[N - k] - s[N];
        else if (j + k + i == N)
          G[j][k] = F[j][k + i];
        else
          G[j][k] = std::min(F[j][k + i], f[j][k + i + 1]);
    }
    for (int j = N; ~j; j--) {
      for (int k = std::min(j + i - 1, N - j); k >= j; k--) f[j][k] = F[j][k];
      for (int k = std::min(j - 1, N - j); k >= j - i && k >= 0; k--)
        g[j][k] = G[j][k];
    }
  }
  printf("%d\n", f[0][0]);
  return 0;
}
