#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
const double eps = 1e-10;
const long long inf = 0x3f3f3f3f3f3f3f3fLL;
const long long N = 2e5 + 5;
const long long MOD = 1e9 + 7;
long long pw(long long b, long long p) {
  b %= MOD;
  long long ans = 1;
  while (p > 0) {
    if (p & 1) ans = ans * b % MOD;
    b = b * b % MOD;
    p >>= 1;
  }
  return ans;
}
long long a[205];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, K;
  cin >> n >> K;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = -inf;
  for (long long i = 0; i < n; i++) {
    for (long long j = i; j < n; j++) {
      vector<long long> x, y;
      for (long long k = 0; k < i; k++) x.push_back(a[k]);
      for (long long k = j + 1; k < n; k++) x.push_back(a[k]);
      for (long long k = i; k <= j; k++) y.push_back(a[k]);
      sort(x.begin(), x.end());
      reverse(x.begin(), x.end());
      sort(y.begin(), y.end());
      for (long long k = 0; k < min(K, (long long)min(x.size(), y.size()));
           k++) {
        if (x[k] > y[k]) {
          swap(x[k], y[k]);
        }
      }
      ans = max(ans, accumulate(y.begin(), y.end(), 0LL));
    }
  }
  cout << ans;
  return 0;
}
