#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int n,k,maxsuma=0;
    cin>>n>>k;
    vector <int> v1,v1r;
    for(int i=0;i<n;i++){
        int x=0;
        cin>>x;
        v1.push_back(x);
        v1r.push_back(x);
    }
    reverse(v1r.begin(),v1r.end());
    int comb=n-k+1;
    vector <int> vall=v1;
    for(int i=0;i<comb;i++){
        vector<int> vtest=vall;
        sort(vtest.begin()+1,vtest.end());
        reverse(vtest.begin()+1,vtest.end());
        int suma=0;
        for(int j=1;j<k;j++){
            suma+=vtest.at(j);
        }
        suma-=vtest.at(0);
        if(suma>maxsuma){
            maxsuma=suma;
        }
        vall.erase(vall.begin());
    }
    vall=v1;
    reverse(vall.begin(),vall.end());
    for(int i=0;i<comb;i++){
        vector<int> vtest=vall;
        sort(vtest.begin()+1,vtest.end());
        reverse(vtest.begin()+1,vtest.end());
        int suma=0;
        for(int j=1;j<k;j++){
            suma+=vtest.at(j);
        }
        suma-=vtest.at(0);
        if(suma>maxsuma){
            maxsuma=suma;
        }
        vall.erase(vall.begin());
    }
    cout<<maxsuma;

}