#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INF64 = 0x3f3f3f3f3f3f3f3f;
const int N = 1e2 + 10;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  int ans = -INF;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      vector<int> in, out;
      for (int x = 0; x < n; ++x) {
        if (x >= i && x <= j)
          in.push_back(a[x]);
        else
          out.push_back(a[x]);
      }
      sort(in.begin(), in.end());
      sort(out.rbegin(), out.rend());
      for (int i = 0; i < min({(int)in.size(), (int)out.size(), k}); ++i) {
        if (out[i] > in[i])
          swap(out[i], in[i]);
        else
          break;
      }
      ans = max(ans, accumulate(in.begin(), in.end(), 0));
    }
  }
  cout << ans << '\n';
  return 0;
}
