#include <bits/stdc++.h>
using namespace std;
int n, k, a[222], s[222], b[222], c[222], w, q, M = -99999, m;
int main() {
  cin >> n >> k;
  s[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    s[i] = s[i - 1] + a[i];
  }
  for (int l = 0; l <= n - 1; l++)
    for (int r = l + 1; r <= n; r++) {
      m = s[r] - s[l];
      w = 0;
      q = 0;
      for (int i = 1; i <= n; i++) {
        if (i > l && i <= r) {
          w++;
          b[w] = a[i];
        } else {
          q++;
          c[q] = a[i];
        }
      }
      sort(b + 1, b + w + 1);
      sort(c + 1, c + q + 1);
      reverse(c + 1, c + q + 1);
      for (int i = 1; i <= min(k, min(q, w)); i++) {
        if (c[i] - b[i] > 0) m = m - b[i] + c[i];
      }
      M = max(M, m);
    }
  cout << M;
  return 0;
}
