#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e3 + 7;
const int mod = 1e9 + 7;
const int INF = 1e9 + 7;
const int maxl = 20;
const int SQ = 70;
int n;
int a[maxn], ps[maxn];
int dp[maxn][SQ][SQ];
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(), cout.tie();
  ;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) ps[i] = ps[i - 1] + a[i];
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < SQ; j++) {
      for (int k = 1; k < SQ; k++) {
        int l = i;
        int r = n - i - j;
        if (l >= r) break;
        dp[i][j][k] = -INF;
        for (int Amove : {k, k + 1}) {
          if (r - l >= Amove) {
            int p1 = 0, p2 = 0;
            for (int Bmove : {Amove, Amove + 1}) {
              if (l + Amove <= r - Bmove)
                p1 = dp[l + Amove][n - l - Amove - r + Bmove][Bmove] +
                     ps[l + Amove] - ps[l] - ps[r] + ps[r - Bmove];
              else
                p1 = +INF;
              swap(p1, p2);
            }
            dp[i][j][k] = max(
                dp[i][j][k],
                (min(p1, p2) == +INF ? ps[l + Amove] - ps[l] : min(p1, p2)));
          }
        }
        dp[i][j][k] = (dp[i][j][k] != -INF ? dp[i][j][k] : 0);
      }
    }
  }
  cout << dp[0][0][1] << "\n";
  return 0;
}
