#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) { return a > b; }
int a[205], b[205], c[205];
int main() {
  int n, k, t, j, i, p1, p2;
  while (scanf("%d%d", &n, &k) != EOF) {
    int ma = -11100000;
    for (i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    for (i = 1; i <= n; i++)
      for (j = i; j <= n; j++) {
        int num1 = 0;
        for (p1 = 1; p1 < i; p1++) {
          b[++num1] = a[p1];
        }
        for (p1 = j + 1; p1 <= n; p1++) b[++num1] = a[p1];
        int num2 = 0;
        int sum = 0;
        for (p1 = i; p1 <= j; p1++) {
          c[++num2] = a[p1];
          sum += a[p1];
        }
        sort(b + 1, b + 1 + num1, cmp);
        sort(c + 1, c + 1 + num2);
        for (p1 = 1; p1 <= k && p1 <= num1 && p1 <= num2; p1++) {
          if (b[p1] > c[p1]) sum += b[p1] - c[p1];
        }
        if (sum > ma) ma = sum;
      }
    printf("%d\n", ma);
  }
}
