#include <bits/stdc++.h>
using namespace std;
int n, k, ans = -200000, temp;
int a[205];
vector<int> in_range, out_range;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int l = 0; l < n; l++) {
    for (int r = l; r < n; r++) {
      int sum = 0;
      temp = k;
      for (int i = l; i <= r; i++) in_range.push_back(a[i]);
      for (int j = 0; j < l; j++) out_range.push_back(a[j]);
      for (int j = r + 1; j < n; j++) out_range.push_back(a[j]);
      sort(in_range.begin(), in_range.end());
      sort(out_range.begin(), out_range.end());
      for (int i = 0;
           i < min((int)out_range.size(), (int)in_range.size()) and temp--;
           i++) {
        if (out_range[(int)out_range.size() - 1 - i] > in_range[i])
          in_range[i] = out_range[(int)out_range.size() - 1 - i];
      }
      for (int i = 0; i < (int)in_range.size(); i++) sum += in_range[i];
      ans = max(sum, ans);
      in_range.clear();
      out_range.clear();
    }
  }
  cout << ans;
}
