#include <bits/stdc++.h>
using namespace std;
int n, k, a[210];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = INT_MIN;
  for (int l = 0; l < n; l++)
    for (int r = l; r < n; r++) {
      vector<int> b;
      for (int j = l; j <= r; j++) b.push_back(a[j]);
      sort(b.begin(), b.end());
      vector<int> c;
      for (int j = 0; j < l; j++) c.push_back(a[j]);
      for (int j = r + 1; j < n; j++) c.push_back(a[j]);
      sort(c.begin(), c.end(), greater<int>());
      int t = min(min(b.size(), c.size()), (size_t)k);
      for (int j = 0; j < t; j++)
        if (c[j] > b[j])
          b[j] = c[j];
        else
          break;
      ans = max(ans, accumulate(b.begin(), b.end(), 0));
    }
  cout << ans << endl;
  return 0;
}
