#include <bits/stdc++.h>
using namespace std;
void swap(int &a, int &b) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
  return;
}
int jum[210][210];
int main() {
  int n, s;
  int a[210];
  scanf("%d %d", &n, &s);
  for (int k = 0; k < n; k++) {
    scanf("%d", &a[k]);
  }
  int x[210];
  int y[210];
  int ret = -2000000;
  for (int l = 0; l < n; l++) {
    for (int r = l; r < n; r++) {
      int px = 0, py = 0;
      for (int i = 0; i < n; i++) {
        if (i < l || i > r) {
          y[py] = a[i];
          py++;
        } else {
          x[px] = a[i];
          px++;
        }
      }
      sort(x, x + px);
      sort(y, y + py);
      int i = 0, k = 0, c = py - 1;
      while (i != px && k != s && c >= 0) {
        if (x[i] < y[c]) {
          swap(x[i], y[c]);
          k++;
          i++;
        }
        c--;
      }
      int jum = 0;
      for (int m = 0; m < px; m++) {
        jum += x[m];
      }
      ret = max(ret, jum);
    }
  }
  printf("%d\n", ret);
  return 0;
}
