#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) { return a > b; }
int main() {
  int n, k, a[205], dp[205] = {0};
  vector<int> s, v;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    dp[i] = a[i] + dp[i - 1];
  }
  int Max = -(int)1e9, L, R;
  for (int l = 1; l <= n; l++) {
    for (int r = l; r <= n; r++) {
      v.clear();
      s.clear();
      for (int i = 1; i <= n; i++) {
        if (i < l || i > r)
          v.push_back(a[i]);
        else
          s.push_back(a[i]);
      }
      sort(s.begin(), s.end());
      sort(v.begin(), v.end(), cmp);
      int ans = dp[r] - dp[l - 1];
      for (int j = 1, i = 0; j <= k && i < s.size() && i < v.size(); j++, i++) {
        if (j > s.size()) break;
        int t1 = s[i], t2 = v[i];
        if (t1 > t2)
          break;
        else {
          ans -= t1;
          ans += t2;
        }
      }
      if (ans > Max) {
        L = l;
        R = r;
        Max = ans;
      }
    }
  }
  cout << Max << endl;
  return 0;
}
