#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> a(n);
  for (long long int i = 0; i < n; i++) cin >> a[i];
  long long int ans = -1e18;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = i; j < n; j++) {
      vector<long long int> in, out;
      long long int sum = 0;
      for (long long int k = 0; k < n; k++) {
        if (k < i || k > j)
          out.push_back(a[k]);
        else
          in.push_back(a[k]), sum += a[k];
      }
      sort((in).begin(), (in).end());
      sort((out).rbegin(), (out).rend());
      long long int l = 0, r = 0, s = k;
      while (l < (long long int)in.size() && r < (long long int)out.size() &&
             s-- > 0) {
        if (in[l] < out[r]) sum += out[r] - in[l];
        l++, r++;
      }
      ans = max(ans, sum);
    }
  }
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int test_cases = 1;
  while (test_cases--) {
    solve();
  }
  return 0;
}
