#include <bits/stdc++.h>
using namespace std;
int compare(const void *a, const void *b) {
  int *p = (int *)a;
  int *q = (int *)b;
  return q[0] - p[0];
}
int compare1(const void *a, const void *b) {
  int *p = (int *)a;
  int *q = (int *)b;
  return p[0] - q[0];
}
int main() {
  int n, k, i, j, a[202], b[202], c[202], p;
  scanf("%d%d", &n, &k);
  ;
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  ;
  int mx = INT_MIN;
  for (i = 0; i < n; i++) {
    for (j = i; j < n; j++) {
      int sum = 0, q = 0;
      for (p = i; p < j + 1; p++) {
        sum += a[p];
        c[q++] = a[p];
      }
      int co = 0, x = 0;
      for (p = 0; p < i; p++) b[co++] = a[p];
      for (p = j + 1; p < n; p++) b[co++] = a[p];
      qsort(b, co, sizeof(int), compare);
      qsort(c, q, sizeof(int), compare1);
      while (x < k && x < co && x < q && b[x] > c[x]) {
        sum += b[x];
        sum -= c[x];
        x++;
      }
      mx = max(mx, sum);
    }
  }
  printf("%d\n", mx);
  return 0;
}
