#include <bits/stdc++.h>
using namespace std;
long long int a[300];
long long int n, k;
long long int maxima(long long int l, long long int r) {
  vector<long long int> naka, soto;
  for (long long int i = 0; i < ((long long int)(n)); i++) {
    if (i >= l && i <= r)
      naka.push_back(a[i]);
    else
      soto.push_back(a[i]);
  }
  sort((naka).begin(), (naka).end());
  sort((soto).begin(), (soto).end());
  long long int kk = k;
  long long int sn = ((long long int)(naka).size()),
                ss = ((long long int)(soto).size());
  for (long long int i = 0; i < ((long long int)(kk)); i++) {
    if (i < sn && ss - i - 1 >= 0 && naka[i] < soto[ss - i - 1]) {
      swap(naka[i], soto[ss - i - 1]);
    } else
      break;
  }
  long long int res = 0;
  for (long long int i = 0; i < ((long long int)(sn)); i++) res += naka[i];
  return res;
}
int main() {
  cin >> n >> k;
  for (long long int i = 0; i < ((long long int)(n)); i++) {
    cin >> a[i];
  }
  long long int res = -99999999;
  for (long long int i = 0; i < ((long long int)(n)); i++) {
    for (long long int j = (long long int)(i); j < ((long long int)(n)); j++) {
      res = max(res, maxima(i, j));
    }
  }
  cout << res << endl;
  return 0;
}
