#include <bits/stdc++.h>
using namespace std;
const int maxn = 207;
int a[maxn], n, k, l1[maxn], l2[maxn], c1, c2;
bool mycmp(const int &a, const int &b) { return a > b; }
int cal(int l, int r) {
  c1 = 0;
  for (int i = 1, _c = l - 1; i <= _c; i++) l1[++c1] = a[i];
  for (int i = r + 1, _c = n; i <= _c; i++) l1[++c1] = a[i];
  c2 = 0;
  int res = 0;
  for (int i = l, _c = r; i <= _c; i++) l2[++c2] = a[i], res += a[i];
  if (c1 > 0) sort(l1 + 1, l1 + c1 + 1, mycmp);
  if (c2 > 0) sort(l2 + 1, l2 + c2 + 1);
  int idx = 1;
  for (int i = 1, _c = min(k, min(c1, c2)); i <= _c; i++) {
    if (l1[i] - l2[i] > 0)
      res += l1[i] - l2[i];
    else
      break;
  }
  return res;
}
int main() {
  cin >> n >> k;
  for (int i = 1, _c = n; i <= _c; i++) cin >> a[i];
  int res = -1000000007;
  for (int i = 1, _c = n; i <= _c; i++)
    for (int j = i, _c = n; j <= _c; j++) {
      res = max(res, cal(i, j));
    }
  cout << res << endl;
}
