#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[210], b[210], c[210];
bool cmp(int x, int y) { return x > y; }
int fin(int l, int r) {
  int sum = 0, k1 = 0;
  memset(b, 0, sizeof(b));
  memset(c, 0, sizeof(c));
  for (int i = l; i <= r; i++) {
    b[k1++] = a[i];
    sum += a[i];
  }
  if (l == 1 && r == n) {
    return sum;
  }
  sort(b, b + k1);
  int kk = 0;
  for (int i = 1; i < l; i++) {
    c[kk++] = a[i];
  }
  for (int i = r + 1; i <= n; i++) {
    c[kk++] = a[i];
  }
  sort(c, c + kk, cmp);
  for (int i = 0; i < k; i++) {
    if (c[i] > b[i]) {
      sum -= b[i];
      sum += c[i];
    } else {
      break;
    }
  }
  return sum;
}
int main() {
  while (scanf("%d%d", &n, &k) != EOF) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    int ans = -10000000;
    for (int i = 1; i <= n; i++) {
      for (int j = i; j <= n; j++) {
        int t = fin(i, j);
        ans = max(ans, t);
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
