#include <bits/stdc++.h>
using namespace std;
const int maxn = 205;
int a[maxn], sum[maxn], cnt[maxn];
priority_queue<int> que1, que2;
int main() {
  int n, k, ans = -1e9;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum[i] = sum[i - 1] + a[i];
    if (a[i] >= 0)
      cnt[i] = cnt[i - 1] + 1;
    else
      cnt[i] = cnt[i - 1];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      while (!que1.empty()) que1.pop();
      while (!que2.empty()) que2.pop();
      int tmp = 0, tot = j - i + 1, now = 0, lim = 0;
      for (int k = 1; k <= n; k++) {
        if (k >= i && k <= j)
          que1.push(a[k]);
        else
          que2.push(a[k]);
      }
      while (now < tot) {
        if (!que2.empty() && que2.top() > que1.top() && lim < k) {
          lim++;
          now++;
          tmp += que2.top();
          que2.pop();
        } else {
          now++;
          tmp += que1.top();
          que1.pop();
        }
      }
      ans = max(ans, tmp);
    }
  }
  printf("%d\n", ans);
  return 0;
}
