#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, j, l, m, max, x, xi, xj, y;
  int a[201], b[201], c[201];
  while (scanf("%d%d", &n, &k) != EOF) {
    c[0] = 0;
    for (i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      c[i] = c[i - 1] + a[i];
    }
    max = -1001;
    for (i = 0; i < n; i++)
      for (j = i + 1; j <= n; j++) {
        y = c[j] - c[i];
        for (l = 1; l <= n; l++) b[l] = a[l];
        sort(b + i + 1, b + j);
        for (l = 0; l < k && l < j - i; l++) {
          b[0] = -1001;
          x = 0;
          for (m = 1; m <= i; m++)
            if (b[x] < b[m]) x = m;
          for (m = j + 1; m <= n; m++)
            if (b[x] < b[m]) x = m;
          if (b[x] > b[i + 1 + l]) {
            y = y - b[i + 1 + l] + b[x];
            b[x] = -1001;
          } else
            break;
        }
        if (max < y) {
          max = y;
        }
      }
    printf("%d\n", max);
  }
}
