#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int a[222], n, kth;
int b[222], c[222];
int main() {
  scanf("%d%d", &n, &kth);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  int ans = -INF;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      int nb = 0, nc = 0, sum = 0;
      for (int k = 0; k < n; k++) {
        if (!(k >= i && k <= j))
          c[nc++] = a[k];
        else {
          sum += a[k];
          b[nb++] = a[k];
        }
      }
      sort(b, b + nb);
      sort(c, c + nc);
      for (int k = 0; k < kth; k++) {
        if (nc - k - 1 >= 0 && k < nb && c[nc - k - 1] > b[k]) {
          sum = sum - b[k] + c[nc - k - 1];
        } else
          break;
      }
      ans = max(ans, sum);
    }
  }
  printf("%d\n", ans);
  return 0;
}
