#include <bits/stdc++.h>
using namespace std;
int a[201], n, k;
int atemp[201];
int left_out[201], sizel = -1;
void copya2atemp() {
  for (__typeof(n) i = 0; i < n; i++) atemp[i] = a[i];
}
void gen_left(int l, int r) {
  sizel = 0;
  for (__typeof(n) i = 0; i < n; i++) {
    if (i < l || i > r) {
      left_out[sizel] = a[i];
      sizel++;
    }
  }
}
int find_rep(int val) {
  int max = -99999, max_idx;
  for (__typeof(sizel) i = 0; i < sizel; i++) {
    if (max < left_out[i]) {
      max = left_out[i];
      max_idx = i;
    }
  }
  if (val < max)
    return max_idx;
  else
    return -1;
}
int getmaxSum(int l, int r) {
  for (__typeof(l + k) i = l; i < l + k; i++) {
    if (i >= n) break;
    int rep = find_rep(atemp[i]);
    if (rep != -1) {
      swap(left_out[rep], atemp[i]);
    } else
      break;
  }
  int sum = 0;
  for (__typeof(r) i = l; i <= r; i++) sum += atemp[i];
  return sum;
}
int main() {
  int sum, max_sum = -99999999;
  cin >> n >> k;
  for (__typeof(n) i = 0; i < n; i++) cin >> a[i];
  for (__typeof(n) i = 0; i < n; i++)
    for (__typeof(n) j = i; j < n; j++) {
      copya2atemp();
      gen_left(i, j);
      sort(atemp + i, atemp + j + 1);
      sum = getmaxSum(i, j);
      if (max_sum < sum) max_sum = sum;
    }
  cout << max_sum << endl;
  return 0;
}
