#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  const int nmax = 200;
  int str[nmax];
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> str[i];
  int ans = 0x80000000;
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++) {
      vector<int> in(str + i, str + j + 1), out(str, str + i),
          out1(str + j + 1, str + n);
      out.insert(out.end(), out1.begin(), out1.end());
      sort(out.begin(), out.end());
      sort(in.begin(), in.end());
      int t = 0, sum = 0;
      for (; t < k && t < in.size() && t < out.size(); t++) {
        if (in[t] < out[out.size() - t - 1])
          sum += out[out.size() - t - 1];
        else
          break;
      }
      for (; t < in.size(); t++) sum += in[t];
      ans = max(ans, sum);
    }
  cout << ans << endl;
  return 0;
}
