#include <bits/stdc++.h>
using namespace std;
int k;
int sum_sub(vector<int> &v, int l, int r) {
  int s = 0, i;
  for (i = l; i <= r; i++) s += v[i];
  return s;
}
int sub_arr(vector<int> v, int l, int r) {
  int i, n = v.size();
  if (l == 0 && r == n - 1) return sum_sub(v, l, r);
  multiset<int> s1, s2;
  multiset<int>::iterator a, b;
  for (i = l; i <= r; i++) s1.insert(v[i]);
  for (i = 0; i < l; i++) s2.insert(v[i]);
  for (i = r + 1; i < n; i++) s2.insert(v[i]);
  for (i = 0; i < k; i++) {
    a = s1.begin();
    b = s2.end();
    b--;
    int A = *a, B = *b;
    if (A >= B) break;
    s1.erase(a);
    s2.erase(b);
    s1.insert(B);
    s2.insert(A);
  }
  int ans = 0;
  for (a = s1.begin(); a != s1.end(); a++) ans += *a;
  return ans;
}
int main() {
  int i, n, ans = -1000000000, j;
  cin >> n >> k;
  vector<int> v(n);
  for (i = 0; i < n; i++) cin >> v[i];
  for (i = 0; i < n; i++)
    for (j = i; j < n; j++) ans = max(ans, sub_arr(v, i, j));
  cout << ans << endl;
  return 0;
}
