#include <bits/stdc++.h>
using namespace std;
int n, k, mx, a[205], top, tk;
vector<int> v1, v2;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  mx = a[1];
  for (int l = 1; l <= n; l++)
    for (int r = l; r <= n; r++) {
      v1.clear();
      v2.clear();
      top = tk = 0;
      for (int i = 1; i <= n; i++)
        if (i >= l and i <= r) {
          v1.push_back(a[i]);
          top += a[i];
        } else
          v2.push_back(a[i]);
      sort(v1.begin(), v1.end());
      sort(v2.begin(), v2.end(), greater<int>());
      for (int i = 0; i <= (int)(min(v1.size(), v2.size())) - 1; i++) {
        if (v1[i] >= v2[i] or tk == k) break;
        top -= v1[i];
        top += v2[i];
        tk++;
      }
      mx = max(mx, top);
    }
  cout << mx << endl;
  return 0;
}
