q1)
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
ll f(int ind, vector <ll> &v ,int cnt,ll &k) {
int n=v.size();
if (ind >= n){
if (cnt == k+1) {
return 0;}
return -1e10;
}
ll ans=-1e18;
ll sum=0;
for (int i=ind;i<n;i++) {
sum+=v[i];
if (cnt%2) {
ans=max(ans , -sum + f(i+1,v,cnt+1,k));
}
else {
ans=max(ans , sum+f(i+1,v,cnt+1,k));
}
}
return ans;
}
int main() {
ll n,k;
cin>>n>>k;
vector <ll> v(n,0);
for (int i=0;i<n;i++) {
cin>>v[i];
}
cout<<f(0,v,1,k);
return 0;
}