#include <bits/stdc++.h>
using namespace std;
const int N = 4010;
const int SQ = 100;
const int inf = 1e9 + 10;
int ps[N];
map<int, int> dp[SQ][2][N];
int cal(int k, int t, int l, int r) {
  if (dp[k][t][l].find(r) != dp[k][t][l].end()) return dp[k][t][l][r];
  if (r - l + 1 < k) return 0;
  if (r - l + 1 == k) return ps[r] - ps[l - 1];
  if (t == 0)
    dp[k][t][l][r] = max(ps[l + k - 1] - ps[l - 1] - cal(k, 1, l + k, r),
                         ps[l + k] - ps[l - 1] - cal(k + 1, 1, l + k + 1, r));
  else
    dp[k][t][l][r] = max(ps[r] - ps[r - k] - cal(k, 0, l, r - k),
                         ps[r] - ps[r - k - 1] - cal(k + 1, 0, l, r - k - 1));
  return dp[k][t][l][r];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> ps[i], ps[i] += ps[i - 1];
  cout << cal(1, 0, 1, n);
  return 0;
}
