#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:268435456")
using namespace std;
void prepare(string s = "") {
  if (s != "") {
    freopen((s + ".in").c_str(), "r", stdin);
  }
}
const int NMAX = 201, INF = 1000000000;
int n, k;
int v[NMAX];
void getData() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
}
void solve() {
  long long ans = -INF;
  for (int l = 0; l < n; ++l) {
    long long sum = 0, s = 0;
    for (int r = l; r < n; ++r) {
      sum += v[r];
      vector<int> a, b;
      for (int i = 0; i < n; ++i) {
        if (i < l || i > r)
          a.push_back(v[i]);
        else
          b.push_back(v[i]);
      }
      sort(a.begin(), a.end());
      sort(b.begin(), b.end());
      s = sum;
      for (int i = 0; i < k; ++i) {
        if (a.size() < 1 + i || b.size() <= i || b[i] >= a[a.size() - i - 1])
          break;
        s -= b[i];
        s += a[a.size() - i - 1];
      }
      ans = max(ans, s);
    }
  }
  cout << ans;
}
int main() {
  prepare();
  getData();
  solve();
  return 0;
}
