#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, max = -100000;
  int a[200], inter[200], exter[200];
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      int sum = 0;
      vector<int> inter, exter;
      inter.clear();
      exter.clear();
      for (int m = i; m < j + 1; m++) {
        sum += a[m];
        inter.push_back(a[m]);
      }
      for (int m = 0; m < i; m++) exter.push_back(a[m]);
      for (int m = j + 1; m < n; m++) exter.push_back(a[m]);
      sort(inter.begin(), inter.end());
      sort(exter.begin(), exter.end());
      for (int m = 0; m < k; m++) {
        if (m >= inter.size() || exter.size() < m + 1) break;
        if (exter[exter.size() - 1 - m] > inter[m])
          sum += exter[exter.size() - 1 - m] - inter[m];
      }
      max = max > sum ? max : sum;
    }
  }
  cout << max << endl;
  return 0;
}
