#include <bits/stdc++.h>
using namespace std;
long long modpow(long long a, long long b,
                 long long mod = (long long)(1e9 + 7)) {
  if (!b) return 1;
  a %= mod;
  return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod;
}
const int maxn = 4e3, sqrtn = 64, infty = int(1e9 + 7);
int n;
int arr[maxn];
int cumul[maxn];
int dp[maxn][2 * sqrtn][2 * sqrtn + 1];
int sum(int lt, int rt) { return cumul[rt] - (lt == 0 ? 0 : cumul[lt - 1]); }
int gans(int lt, int d, int k) {
  if (dp[lt][d][k] != infty) return dp[lt][d][k];
  int rt = n - 1 - lt - d;
  if (rt < lt || rt - lt + 1 < k)
    return dp[lt][d][k] = 0;
  else {
    dp[lt][d][k] = -infty;
    (dp[lt][d][k]) =
        max((dp[lt][d][k]),
            (min(sum(lt, lt + k - 1) -
                     (rt - k + 1 > lt + k - 1 ? sum(rt - k + 1, rt) : 0) +
                     gans(lt + k, d, k),
                 sum(lt, lt + k - 1) -
                     (rt - k > lt + k - 1 ? sum(rt - k, rt) : -infty) +
                     gans(lt + k, d + 1, k + 1))));
    ;
    if (rt - lt + 1 >= k + 1)
      (dp[lt][d][k]) =
          max((dp[lt][d][k]),
              (min(sum(lt, lt + k) - (rt - k > lt + k ? sum(rt - k, rt) : 0) +
                       gans(lt + k + 1, d, k + 1),
                   sum(lt, lt + k) -
                       (rt - k - 1 > lt + k ? sum(rt - k - 1, rt) : -infty) +
                       gans(lt + k + 1, d + 1, k + 2))));
    ;
    return dp[lt][d][k];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  scanf("%d", &n);
  for (int k = 0; k < sqrtn + 1; k++)
    for (int lt = 0; lt < n; lt++)
      for (int d = 0; d < sqrtn; d++) dp[lt][d][k] = infty;
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  cumul[0] = arr[0];
  for (int i = 0; i < n; i++)
    if (i) cumul[i] = cumul[i - 1] + arr[i];
  cout << gans(0, 0, 1) << endl;
  return 0;
}
