#include <bits/stdc++.h>   using namespace std;   int n = 0;   vector<int> v;   int flag[2010];   int countt = 0;   int k = 0;   int maxt = 0;   int main() {     cin >> n;     cin >> k;     for (int i = 0; i < n; i++) {       int kari = 0;       cin >> kari;       v.push_back(kari);       if (i == 0) {         maxt = kari;       } else {         maxt = max(maxt, kari);       }     }     for (int i = 0; i < n; i++) {       for (int j = i + 1; j < n; j++) {         vector<int> u;         vector<int> d;         u.clear();         d.clear();         int sum = 0;         for (int jj = 0; jj < n; jj++) {           if (jj < i || j < jj) {             d.push_back(v[jj]);           } else {             sum += v[jj];             u.push_back(v[jj]);           }         }         sort(u.begin(), u.end());         sort(d.begin(), d.end());         maxt = max(maxt, sum);         {           int ii = 0;           int jj = d.size() - 1;           for (; ii < u.size() && jj >= 0 && ii < k; ii++, jj--) {             sum -= u[ii];             sum += d[jj];             maxt = max(maxt, sum);           }         }       }     }     cout << maxt << endl;     return 0;   }   