#include <bits/stdc++.h>
using namespace std;
const int INF = 987654321;
int n, k, sol = -INF, A[210];
int calc(int lo, int hi) {
  priority_queue<int> mmax, mmin;
  int ret = -INF, sum = 0;
  for (int i = 0; i < n; ++i) {
    if (i < lo || hi < i) {
      mmax.push(A[i]);
    } else {
      mmin.push(-A[i]);
      sum += A[i];
    }
  }
  ret = sum;
  int repeat = k;
  while (repeat--) {
    if (mmax.size() && mmin.size()) {
      int a = -mmin.top();
      mmin.pop();
      int b = mmax.top();
      mmax.pop();
      sum -= a;
      sum += b;
      ret = max(ret, sum);
      mmax.push(a);
      mmin.push(-b);
    }
  }
  return ret;
}
int main() {
  scanf("%d%d", &n, &k);
  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) {
      sol = max(sol, calc(i, j));
    }
  }
  printf("%d\n", sol);
}
