#include <bits/stdc++.h>
using namespace std;
int a[205];
int tmp[205], tsz;
int tmp1[205], tsz1;
int n, k;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  int ans = -1000000000;
  for (int l = 0; l < n; ++l) {
    for (int r = l + 1; r <= n; ++r) {
      int sum = 0;
      tsz = tsz1 = 0;
      for (int i = 0; i < n; ++i) {
        if (i >= l && i < r) {
          sum += a[i];
          tmp1[tsz1++] = a[i];
        } else
          tmp[tsz++] = a[i];
      }
      sort(tmp, tmp + tsz);
      sort(tmp1, tmp1 + tsz1);
      reverse(tmp, tmp + tsz);
      int q = min(min(k, tsz), tsz1);
      for (int i = 0; i < q; ++i)
        if (tmp1[i] < tmp[i]) sum += tmp[i] - tmp1[i];
      ans = max(ans, sum);
    }
  }
  cout << ans << endl;
  return 0;
}
