#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
int lcm(int x, int y) { return x * y / gcd(x, y); }
int n, k;
int a[201];
const int INF = 98765432;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("\n%d", &a[i]);
  int ret = -INF;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      vector<int> choose, left;
      int sum = 0;
      for (int l = 0; l < n; ++l) {
        if (l < i || l > j)
          left.push_back(a[l]);
        else {
          choose.push_back(a[l]);
          sum += a[l];
        }
      }
      if (left.size() == 0) {
        ret = max(ret, sum);
        continue;
      }
      sort(choose.begin(), choose.end());
      sort(left.begin(), left.end());
      int cidx = 0, lidx = left.size() - 1, swapped = 0;
      while (true) {
        if (swapped >= k) break;
        if (cidx >= choose.size()) break;
        if (lidx < 0) break;
        if (choose[cidx] < left[lidx]) {
          swapped++;
          sum = sum - choose[cidx] + left[lidx];
          cidx++;
          lidx--;
        } else
          break;
      }
      ret = max(ret, sum);
    }
  }
  printf("%d\n", ret);
  return 0;
}
