#include <bits/stdc++.h>
using namespace std;
const int INF = 10000000;
long long int a[200 + 50], n, k, ans = -INF;
vector<int> v1, v2;
int main() {
  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++) {
      v1.clear();
      v2.clear();
      long long int sum = 0;
      for (int k = i; k <= j; k++) {
        v1.push_back(a[k]);
        sum += a[k];
      }
      for (int k = 0; k < i; k++) {
        v2.push_back(a[k]);
      }
      for (int k = j + 1; k < n; k++) {
        v2.push_back(a[k]);
      }
      sort(v1.begin(), v1.end());
      sort(v2.begin(), v2.end());
      reverse(v2.begin(), v2.end());
      int t = 0, r = 0, l = 0;
      while (r < v2.size() and t < k) {
        if (l == v1.size()) {
          ans = max(ans, sum);
          break;
        }
        if (v1[l] < v2[r]) {
          sum -= v1[l];
          sum += v2[r];
          t++;
          r++;
          l++;
        } else {
          r++;
        }
      }
      ans = max(ans, sum);
    }
  }
  cout << ans;
}
