#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int res = INT_MIN;
  for (int l = 0; l < n; l++) {
    for (int r = l; r < n; r++) {
      vector<int> x, y;
      for (int i = 0; i < n; i++) {
        if (l <= i && i <= r) {
          x.push_back(a[i]);
        } else {
          y.push_back(a[i]);
        }
      }
      sort(begin(x), end(x));
      sort(begin(y), end(y), greater<int>());
      int j = 0;
      for (int i = 0; i < k; i++, j++) {
        if (j == (int)x.size() || j == (int)y.size() || x[j] > y[j]) {
          break;
        }
        x[j] = y[j];
      }
      int cur = 0;
      for (int i = 0; i < (int)x.size(); i++) {
        cur += x[i];
      }
      res = max(res, cur);
    }
  }
  cout << res << "\n";
  return 0;
}
