#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
const int MXN = 4e3 + 10;
const int SQR = 100;
const int INF = 1e9;
int n;
int A[MXN], ps[MXN];
map<int, int> dp[2][SQR][MXN];
inline int Get(int l, int r) { return ps[r] - ps[l - 1]; }
int memo(int l, int r, int k, int turn) {
  if (r < l) return 0;
  if (dp[turn][k][l].count(r)) {
    return dp[turn][k][l][r];
  }
  int ans;
  bool f = false;
  if (turn) {
    ans = -INF;
    if (l + k - 1 <= r)
      ans = max(ans, memo(l + k, r, k, !turn) + Get(l, l + k - 1)), f = true;
    if (l + k <= r)
      ans = max(ans, memo(l + k + 1, r, k + 1, !turn) + Get(l, l + k)),
      f = true;
  } else {
    ans = INF;
    if (r - k + 1 >= l)
      ans = min(ans, memo(l, r - k, k, !turn) - Get(r - k + 1, r)), f = true;
    if (r - k >= l)
      ans = min(ans, memo(l, r - k - 1, k + 1, !turn) - Get(r - k, r)),
      f = true;
  }
  if (!f) {
    return (dp[turn][k][l][r] = 0);
  }
  return (dp[turn][k][l][r] = ans);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> A[i], ps[i] = ps[i - 1] + A[i];
  cout << memo(1, n, 1, 1) << '\n';
  return 0;
}
