#include <stdio.h>
int N, v[10000];
long long dp[10000][2];
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))
int main() {
while (scanf("%d", &N
) != EOF
) { for (int i = 0; i < N; ++i) {
}
for (int i = 0; i < N - 1; ++i) {
dp[i][0] = max(v[i], v[i + 1]);
}
int turn = 0;
int pastTurn = 1;
for (int intervalSize = 4; intervalSize <= N; intervalSize += 2) {
pastTurn = turn;
turn = (!(turn & 1));
for (int i = 0, j = intervalSize - 1; j < N; ++i, ++j) {
dp[i][turn] = max(v[i] + min(dp[i + 1][pastTurn], dp[i + 2][pastTurn]),
v[j] + min(dp[i][pastTurn], dp[i + 1][pastTurn]));
}
}
printf("%lld\n", dp
[0][turn
]); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgTiwgdlsxMDAwMF07CmxvbmcgbG9uZyBkcFsxMDAwMF1bMl07CiAKI2RlZmluZSBtYXgoeCwgeSkgKCh4KSA+ICh5KSA/ICh4KSA6ICh5KSkKI2RlZmluZSBtaW4oeCwgeSkgKCh4KSA8ICh5KSA/ICh4KSA6ICh5KSkKIAppbnQgbWFpbigpIHsgICAKICAgIHdoaWxlIChzY2FuZigiJWQiLCAmTikgIT0gRU9GKSB7ICAgCiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBOOyArK2kpIHsKICAgICAgICAgICAgc2NhbmYoIiVkIiwgJnZbaV0pOwogICAgICAgIH0KICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IE4gLSAxOyArK2kpIHsKICAgICAgICAgICAgZHBbaV1bMF0gPSBtYXgodltpXSwgdltpICsgMV0pOwogICAgICAgIH0KICAgICAgICBpbnQgdHVybiA9IDA7CiAgICAgICAgaW50IHBhc3RUdXJuID0gMTsKICAgICAgICBmb3IgKGludCBpbnRlcnZhbFNpemUgPSA0OyBpbnRlcnZhbFNpemUgPD0gTjsgaW50ZXJ2YWxTaXplICs9IDIpIHsKICAgICAgICAgICAgcGFzdFR1cm4gPSB0dXJuOwogICAgICAgICAgICB0dXJuID0gKCEodHVybiAmIDEpKTsKICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAsIGogPSBpbnRlcnZhbFNpemUgLSAxOyBqIDwgTjsgKytpLCArK2opIHsKICAgICAgICAgICAgICAgIGRwW2ldW3R1cm5dID0gbWF4KHZbaV0gKyBtaW4oZHBbaSArIDFdW3Bhc3RUdXJuXSwgZHBbaSArIDJdW3Bhc3RUdXJuXSksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2W2pdICsgbWluKGRwW2ldW3Bhc3RUdXJuXSwgZHBbaSArIDFdW3Bhc3RUdXJuXSkpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHByaW50ZigiJWxsZFxuIiwgZHBbMF1bdHVybl0pOwogICAgfQogICAgcmV0dXJuIDA7Cn0=