#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3")
using namespace std;
inline void opting() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
}
int inp() {
  int x;
  cin >> x;
  return x;
}
void make_unique(vector<int> &vec, bool sorted = false) {
  if (sorted) sort((vec).begin(), (vec).end());
  vec.resize(unique((vec).begin(), (vec).end()) - vec.begin());
}
void file_edit(bool reader = true, bool writer = false) {
  if (reader) freopen("Test_input.txt", "r", stdin);
  if (writer) freopen("Test_output.txt", "w", stdout);
}
const int SQRT = 65, lg = 20, inlim = 2147483647;
const int maxn = 4e3 + 10, inf = 1e9 + 420, delta = 1e9 + 9;
int dp[maxn][maxn][2][2];
vector<int> part, v;
int n;
inline int get_range(int l, int r) { return part[r] - part[l] + v[l]; }
int solve() {
  for (int k = SQRT; k; k--)
    for (int sz = 0; sz <= n; sz++)
      for (int i = max(0, (n - sz - SQRT) / 2);
           2 * i <= min(2 * n, n - sz + SQRT); i++) {
        int j = n - i - sz;
        if (j < 0 or j > n) continue;
        if (sz < k) {
          dp[i][j][k & 1][0] = dp[i][j][k & 1][1] =
              get_range(0, i) - get_range(n - j + 1, n + 1);
        }
        if (sz == k) {
          dp[i][j][k & 1][0] = dp[i + k][j][k & 1][1];
          dp[i][j][k & 1][1] = dp[i][j + k][k & 1][0];
        }
        if (sz > k) {
          dp[i][j][k & 1][0] =
              max(dp[i + k][j][k & 1][1], dp[i + k + 1][j][(k + 1) & 1][1]);
          dp[i][j][k & 1][1] =
              min(dp[i][j + k][k & 1][0], dp[i][j + k + 1][(k + 1) & 1][0]);
        }
      }
  return dp[0][0][1][0];
}
void input() {
  n = inp();
  part.push_back(0);
  v.push_back(0);
  for (int i = 1; i <= n; i++) {
    v.push_back(inp());
    part.push_back(v[i] + part[i - 1]);
  }
  part.push_back(part[n]);
  v.push_back(0);
  part.push_back(part[n]);
  v.push_back(0);
  part.push_back(part[n]);
  v.push_back(0);
  part.push_back(part[n]);
  v.push_back(0);
}
int main() {
  opting();
  input();
  cout << solve() << endl;
  return 0;
  while (1) {
    int i, j, k, p;
    cin >> i >> j >> k >> p;
    cout << dp[i][j][k][p] << endl;
  }
}
