#include <bits/stdc++.h>
using namespace std;
int a[222], k, n;
int process(int l, int r) {
  int sum = 0, sz = r - l + 1, popped = 0;
  priority_queue<int> in, out;
  for (int i = 1; i <= n; i++)
    if (l <= i && i <= r)
      in.push(a[i]);
    else
      out.push(a[i]);
  for (int i = 0; i < sz - k; i++) {
    sum += in.top();
    in.pop();
    popped++;
  }
  while (!in.empty()) {
    out.push(in.top());
    in.pop();
  }
  for (int i = 0; i < sz - popped; i++) {
    sum += out.top();
    out.pop();
  }
  return sum;
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int ans = -987654321;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      ans = max(ans, process(i, j));
    }
  }
  cout << ans;
}
