#include <bits/stdc++.h>
using namespace std;
const int maxN = 222;
int n, K, a[maxN];
int main() {
  scanf("%d%d", &n, &K);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int x[maxN], y[maxN], nx, ny;
  int res = a[0];
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++) {
      nx = ny = 0;
      for (int k = 0; k < n; k++)
        if (i <= k && k <= j)
          x[nx++] = a[k];
        else
          y[ny++] = a[k];
      sort(x, x + nx);
      sort(y, y + ny, greater<int>());
      for (int k = 0, yk = 0; k < nx && k < K && yk < ny; k++)
        if (x[k] < y[yk]) swap(x[k], y[yk++]);
      int all = 0;
      for (int k = 0; k < nx; k++) all += x[k];
      res = max(res, all);
    }
  printf("%d\n", res);
  return 0;
}
