#include <bits/stdc++.h>
int main(int argc, char **argv) {
  int k, n;
  std::cin >> n >> k;
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
  }
  int best = std::numeric_limits<int>::min();
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      std::vector<int> sec(std::begin(a) + i, std::begin(a) + j + 1);
      std::vector<int> res;
      for (int k = 0; k < i; ++k) {
        res.push_back(a[k]);
      }
      for (int k = j + 1; k < n; ++k) {
        res.push_back(a[k]);
      }
      std::sort(std::begin(sec), std::end(sec));
      std::sort(std::begin(res), std::end(res));
      auto in_end =
          res.rbegin() + std::min(std::min<size_t>(res.size(), k), sec.size());
      auto out = sec.begin();
      for (auto in = res.rbegin(); in != in_end && *in > *out; ++in, ++out) {
        *out = *in;
      }
      best = std::max(std::accumulate(std::begin(sec), std::end(sec), 0), best);
      std::cout << std::endl;
    }
  }
  std::cout << best << std::endl;
  return 0;
}
