#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, kk, a[200];
  scanf("%d%d", &n, &kk);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int sum, tp, mx = a[0];
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++) {
      priority_queue<int> la, sm;
      sum = 0;
      for (int k = 0; k < n; k++)
        if (k >= i && k <= j) {
          sm.push(-a[k]);
          sum += a[k];
        } else
          la.push(a[k]);
      if (mx < sum) mx = sum;
      int ts = sum;
      for (int k = 0; k < kk; k++) {
        sum += sm.top();
        la.push(-sm.top());
        sm.pop();
        sum += la.top();
        sm.push(-la.top());
        la.pop();
        if (ts >= sum) break;
      }
      if (mx < sum) mx = sum;
    }
  printf("%d", mx);
  return 0;
}
