#include <bits/stdc++.h>
using namespace std;
int main() {
  int numbers[200 + 10];
  int i, n, m;
  scanf(" %d %d", &n, &m);
  for (i = 0; i < n; i++) scanf(" %d", &numbers[i]);
  vector<int> vitor, bahir;
  int m1, l, r, sum, ans;
  ans = -1 << 28;
  for (l = 0; l < n; l++) {
    for (r = l; r < n; r++) {
      i = 0;
      vitor.clear();
      bahir.clear();
      while (i < n) {
        if (i >= l && i <= r)
          vitor.push_back(numbers[i]);
        else
          bahir.push_back(numbers[i]);
        i++;
      }
      sort(vitor.begin(), vitor.end());
      sort(bahir.rbegin(), bahir.rend());
      i = 0;
      m1 = m;
      while (m1 && i < vitor.size() && i < bahir.size()) {
        if (vitor[i] < bahir[i]) {
          m1--;
          vitor[i] = bahir[i];
        }
        i++;
      }
      sum = 0;
      for (i = 0; i < vitor.size(); i++) sum += vitor[i];
      ans = max(ans, sum);
    }
  }
  printf("%d\n", ans);
  return 0;
}
