#include <iostream>
#include <vector>
#include <limits.h>
using namespace std;
int sum[190][90][3];
int solution(vector<int> &arr, int l, int k, int p){
if(sum[l][k][p]){
return sum[l][k][p];
}
int ans = 0;
if(arr.size() - l <= k){
for(int i = l; i < arr.size(); i++){
ans += arr[i];
}
if(p == 2){
sum[l][k][p] = 0;
return sum[l][k][p];
}
sum[l][k][p] = ans;
return sum[l][k][p];
}
if(p == 1){
int temp = 0;
for(int i = 1; i <= k; i++){
temp += arr[(l-1) + i];
ans = max(ans, temp + solution(arr, l+i, i, 3-p));
}
sum[l][k][p] = ans;
return sum[l][k][p];
}
else{
int ans = INT_MAX;
for(int i = 1; i <= k; i++){
ans = min(ans, solution(arr, l+i, i, 3-p));
}
sum[l][k][p] = ans;
return sum[l][k][p];
}
}
int main() {
int n, k, a;
vector<int> coins;
cin >> n;
for(int i = 0; i < n; i++){
cin >> a;
coins.push_back(a);
}
cin >> k;
cout << solution(coins, 0, k, 1);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8bGltaXRzLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgc3VtWzE5MF1bOTBdWzNdOwoKaW50IHNvbHV0aW9uKHZlY3RvcjxpbnQ+ICZhcnIsIGludCBsLCBpbnQgaywgaW50IHApewoJaWYoc3VtW2xdW2tdW3BdKXsKCQlyZXR1cm4gc3VtW2xdW2tdW3BdOwoJfQoJaW50IGFucyA9IDA7CglpZihhcnIuc2l6ZSgpIC0gbCA8PSBrKXsKCQlmb3IoaW50IGkgPSBsOyBpIDwgYXJyLnNpemUoKTsgaSsrKXsKCQkJYW5zICs9IGFycltpXTsKCQl9CgkJaWYocCA9PSAyKXsKCQkJc3VtW2xdW2tdW3BdID0gMDsKCQkJcmV0dXJuIHN1bVtsXVtrXVtwXTsKCQl9CgkJc3VtW2xdW2tdW3BdID0gYW5zOwoJCXJldHVybiBzdW1bbF1ba11bcF07Cgl9Cglp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