#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, kk;
  int best = INT_MIN;
  scanf("%d %d", &n, &kk);
  vector<int> a(n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      vector<int> in, out;
      for (int k = 0; k < n; k++) {
        if (k >= i && k <= j) {
          in.push_back(a[k]);
        } else {
          out.push_back(a[k]);
        }
      }
      sort(in.begin(), in.end());
      sort(out.rbegin(), out.rend());
      for (int k = 0; k < kk && k < in.size() && k < out.size(); k++) {
        if (in[k] < out[k])
          swap(in[k], out[k]);
        else
          break;
      }
      int total = 0;
      for (int k = 0; k < in.size(); k++) total += in[k];
      best = max(total, best);
    }
  }
  printf("%d\n", best);
  return 0;
}
