#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 123;
const int N = 1e6 + 123;
const int INF = 1e9 + 1;
const long long INFL = 3e18 + 1;
const double pi = acos(-1.0);
const double eps = 1e-9;
int n, k, pref[201], a[201], ans = -INF;
int doing(int l, int r) {
  vector<int> g, t;
  for (int i = l; i <= r; i++) g.push_back(a[i]);
  for (int i = 1; i <= l - 1; i++) t.push_back(a[i]);
  for (int i = r + 1; i <= n; i++) t.push_back(a[i]);
  sort(g.begin(), g.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  int cur = pref[r] - pref[l - 1];
  int ans = cur;
  int sum = 0, sum2 = 0;
  for (int i = 1; i <= k; i++) {
    if (sum >= g.size() || sum2 >= t.size()) break;
    cur -= g[sum], sum++;
    cur += t[sum2], sum2++;
    ans = max(ans, cur);
  }
  return ans;
}
inline void boost() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
}
inline void solve() {
  boost();
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pref[i] = pref[i - 1] + a[i];
  }
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++) ans = max(ans, doing(i, j));
  cout << ans;
}
int main() { solve(); }
