#include <bits/stdc++.h>
using namespace std;
int v[220], n, k, ans = 0xbfbfbfbf;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> v[i];
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++) {
      priority_queue<int> mx;
      priority_queue<int, vector<int>, greater<int>> mn;
      for (int t = 1; t < i; t++) mx.push(v[t]);
      for (int t = j + 1; t <= n; t++) mx.push(v[t]);
      int sum = 0;
      for (int t = i; t <= j; t++) mn.push(v[t]), sum += v[t];
      ans = max(ans, sum);
      for (int t = 1; t <= k && !mx.empty() && !mn.empty(); t++) {
        if (mn.top() < mx.top())
          sum -= mn.top(), sum += mx.top(), mn.pop(), mx.pop();
        else
          break;
      }
      ans = max(ans, sum);
    }
  cout << ans;
}
