#include <bits/stdc++.h>
using namespace std;
int n, k, a[205], ans = -99990000;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      vector<int> u, v;
      for (int m = 0; m < n; m++) {
        if (m >= i && m <= j)
          u.push_back(a[m]);
        else
          v.push_back(a[m]);
      }
      sort(u.begin(), u.end());
      sort(v.begin(), v.end());
      reverse(v.begin(), v.end());
      int ind = 0, t = k;
      while (ind < u.size() && ind < v.size() && u[ind] < v[ind] && t > 0) {
        int t2 = u[ind];
        u[ind] = v[ind];
        v[ind++] = t2;
        t--;
      }
      int s = 0;
      for (int i = 0; i < u.size(); i++) s += u[i];
      if (s > ans) {
        for (int i = 0; i < u.size(); i++) ans = s;
      }
    }
  }
  cout << ans;
  return 0;
}
