#include <bits/stdc++.h>
using namespace std;
int dp[2 * 4001 * 4001 * 2];
int s[4001];
int a[4001];
int main() {
  int n;
  scanf("%d", &n);
  s[0] = 0;
  for (int i(1); i <= n; i++) {
    scanf("%d", &a[i]);
    s[i] = s[i - 1] + a[i];
  }
  memset(dp, 0x80, sizeof(dp));
  int cur(0);
  for (int k(100); k >= 1; k--) {
    int mn(k == 1 ? 0 : k * (k - 1) / 2);
    int os(k % 2 == 1 ? k / 2 * (k + 1) / 2 : k / 2 * k / 2 - 1);
    for (int len(0); len <= n; len++) {
      for (int i(1); i + len - 1 <= n; i++) {
        int j(i + len - 1);
        if (abs(i - 1 - n + j) <= k) {
        } else {
          continue;
        }
        if (len < k) {
          dp[((cur) * (4001 * 4001 * 2) + (i) * (4001 * 2) + (j)*2 + (0))] =
              dp[((cur) * (4001 * 4001 * 2) + (i) * (4001 * 2) + (j)*2 + (1))] =
                  s[i - 1] - (s[n] - s[j]);
        } else {
          dp[((cur) * (4001 * 4001 * 2) + (i) * (4001 * 2) + (j)*2 + (0))] =
              dp[((cur) * (4001 * 4001 * 2) + (i + k) * (4001 * 2) + (j)*2 +
                  (1))];
          dp[((cur) * (4001 * 4001 * 2) + (i) * (4001 * 2) + (j)*2 + (1))] =
              dp[((cur) * (4001 * 4001 * 2) + (i) * (4001 * 2) + (j - k) * 2 +
                  (0))];
          if (k != 100 && len >= k + 1) {
            dp[((cur) * (4001 * 4001 * 2) + (i) * (4001 * 2) + (j)*2 + (0))] =
                max(dp[((cur) * (4001 * 4001 * 2) + (i) * (4001 * 2) + (j)*2 +
                        (0))],
                    dp[((cur ^ 1) * (4001 * 4001 * 2) +
                        (i + k + 1) * (4001 * 2) + (j)*2 + (1))]);
            dp[((cur) * (4001 * 4001 * 2) + (i) * (4001 * 2) + (j)*2 + (1))] =
                min(dp[((cur) * (4001 * 4001 * 2) + (i) * (4001 * 2) + (j)*2 +
                        (1))],
                    dp[((cur ^ 1) * (4001 * 4001 * 2) + (i) * (4001 * 2) +
                        (j - k - 1) * 2 + (0))]);
          }
        }
      }
    }
    cur ^= 1;
  }
  cout << dp[((cur ^ 1) * (4001 * 4001 * 2) + (1) * (4001 * 2) + (n)*2 + (0))]
       << endl;
}
