#include <bits/stdc++.h>
using namespace std;
int a[205];
int main() {
  int n, k, sum, ans = -10000000, i, j, s1, s2, p;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    for (p = i; p < n; p++) {
      vector<int> b, c;
      sum = 0;
      for (j = 0; j < n; j++) {
        if (j >= i && j <= p) {
          b.push_back(a[j]);
          sum += a[j];
        } else
          c.push_back(a[j]);
      }
      sort(b.begin(), b.end());
      sort(c.begin(), c.end(), greater<int>());
      s1 = s2 = 0;
      for (j = 0; j < k && j < b.size() && j < c.size(); j++) {
        if (c[j] < b[j]) {
          break;
        }
        s1 += b[j];
        s2 += c[j];
      }
      sum += s2 - s1;
      ans = ((ans) > (sum) ? (ans) : (sum));
    }
  }
  cout << ans << endl;
  return 0;
}
