#include <bits/stdc++.h>
using namespace std;
const int maxn = 200 + 20;
int a[maxn];
int sum[maxn];
bool vis[maxn];
int n, k;
const int INF = 0X3F3F3F3F;
int cal(int l, int r) {
  priority_queue<int, vector<int>, greater<int> > q;
  int ret = 0;
  memset(vis, false, sizeof(vis));
  for (int i = l; i <= r; i++) {
    ret += a[i];
    q.push(a[i]);
  }
  int ktmp = k;
  while (ktmp > 0) {
    int maxt = -INF;
    int maxv;
    for (int i = 1; i <= n; i++) {
      if ((i >= l && i <= r) || vis[i]) continue;
      if (a[i] > maxt) {
        maxt = a[i];
        maxv = i;
      }
    }
    if (maxt > q.top()) {
      ret = ret - q.top() + maxt;
      vis[maxv] = true;
      q.pop();
      q.push(maxt);
    }
    ktmp--;
  }
  return ret;
}
int main() {
  while (~scanf("%d%d", &n, &k)) {
    memset(sum, 0, sizeof(sum));
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      sum[i] = sum[i - 1] + a[i];
    }
    int ans = -INF;
    for (int i = 1; i <= n; i++) {
      for (int j = i; j <= n; j++) {
        int tmp = cal(i, j);
        if (tmp > ans) ans = tmp;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
