#include <bits/stdc++.h>
using namespace std;
template <class T>
T Maximize(T &v, T nv) {
  if (nv > v) v = nv;
  return v;
}
template <class T>
T Minimize(T &v, T nv) {
  if (nv < v) v = nv;
  return v;
}
const long long INFLL = LONG_LONG_MAX;
const long INF = LONG_MAX, N = 201;
long a[N];
void solve() {
  long n, k;
  scanf("%ld %ld", &n, &k);
  multiset<long, greater<long> > available;
  for (long i = 0; i < n; ++i) {
    scanf("%ld", a + i);
    available.insert(a[i]);
  }
  long ans = -INF;
  for (long l = 0; l < n; ++l) {
    multiset<long> s;
    long sum = 0;
    for (long r = l; r < n; ++r) {
      available.erase(available.find(a[r]));
      s.insert(a[r]);
      sum += a[r];
      vector<long> used, deleted;
      used.reserve(k), deleted.reserve(k);
      long res = sum;
      for (long i = 0; i < k; ++i) {
        if (s.empty() || available.empty()) break;
        long a = *s.begin(), b = *available.begin();
        if (b > a) {
          deleted.push_back(a);
          used.push_back(b);
          s.erase(s.begin());
          available.erase(available.begin());
          res += b - a;
        } else {
          break;
        }
      }
      Maximize(ans, res);
      for (long i = 0, sz = deleted.size(); i < sz; ++i) {
        s.insert(deleted[i]);
        available.insert(used[i]);
      }
    }
    sum -= a[l];
    for (long i = l + 1; i < n; ++i) available.insert(a[i]);
    available.insert(a[l]);
  }
  printf("%ld\n", ans);
}
void init() { freopen("input.txt", "r", stdin); }
int main() {
  solve();
  return 0;
}
