#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 2;
const int INF = 1e9 + 1;
const double EPS = 1e-9;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  int a[MAXN];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int ans = -INF;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      vector<int> in;
      vector<int> out;
      for (int q = 0; q < i; ++q) out.push_back(a[q]);
      for (int q = i; q <= j; ++q) in.push_back(a[q]);
      for (int q = j + 1; q < n; ++q) out.push_back(a[q]);
      sort(out.rbegin(), out.rend());
      sort(in.begin(), in.end());
      int ini = 0, outi = 0, q = 0;
      while (ini < in.size() && outi < out.size() && in[ini] < out[outi] &&
             q < k) {
        swap(in[ini++], out[outi++]);
        ++q;
      }
      int crt = 0;
      for (q = 0; q < in.size(); ++q) crt += in[q];
      if (crt > ans) ans = crt;
    }
  }
  cout << ans;
  return 0;
}
