#include <bits/stdc++.h>
using namespace std;
int a[205], b[205], c[205], nb, nc;
int main() {
  int i, j, m, n, k, st, l, vmin, mini, vmax, maxi, ed, sum, ans = -1005;
  scanf("%d%d", &n, &k);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 1; i <= n; i++) {
    for (st = 1; st <= n - i + 1; st++) {
      ed = st + i - 1;
      nb = 0;
      nc = 0;
      for (j = 1; j <= n; j++) {
        if (j >= st && j <= ed)
          b[++nb] = a[j];
        else
          c[++nc] = a[j];
      }
      sort(b + 1, b + nb + 1);
      sort(c + 1, c + nc + 1);
      sum = 0;
      for (l = 1; l <= nb; l++) {
        sum += b[l];
      }
      ans = max(ans, sum);
      for (l = 1; l <= k; l++) {
        if (l <= nb && nc - l + 1 >= 1) {
          if (b[l] < c[nc - l + 1]) {
            sum += c[nc - l + 1] - b[l];
            ans = max(ans, sum);
          } else
            break;
        } else
          break;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
