#include <bits/stdc++.h>
using namespace std;
int n, k;
int x, y;
int ar[310];
int temp1[310];
int temp2[310];
bool cmp(int a, int b) { return a > b; }
int main() {
  int i, l, r;
  int res = -1000000000;
  scanf(" %d %d", &n, &k);
  for (i = 1; i <= n; i++) scanf(" %d", &ar[i]);
  for (l = 1; l <= n; l++)
    for (r = l; r <= n; r++) {
      x = 0;
      y = 0;
      int top = 0;
      for (i = 1; i <= n; i++) {
        if (i < l || i > r)
          temp1[++x] = ar[i];
        else
          temp2[++y] = ar[i];
      }
      sort(temp1 + 1, temp1 + x + 1, cmp);
      sort(temp2 + 1, temp2 + y + 1);
      for (i = 1; i <= min(min(y, k), x); i++) {
        if (temp1[i] < temp2[i]) break;
        swap(temp1[i], temp2[i]);
      }
      for (i = 1; i <= y; i++) top += temp2[i];
      res = max(res, top);
    }
  printf("%d\n", res);
  return 0;
}
