#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long n, x;
long long a[N];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> x;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long ans = -1000;
  for (long long i = 1; i <= n; i++) {
    for (long long j = i; j <= n; j++) {
      long long curans = 0;
      priority_queue<long long, vector<long long> > pq;
      priority_queue<long long, vector<long long>, greater<long long> > pq2;
      for (long long k = 1; k <= n; k++) {
        if (k >= i && k <= j) {
          curans += a[k];
          pq2.push(a[k]);
        } else
          pq.push(a[k]);
      }
      ans = max(ans, curans);
      for (long long k = 1; k <= x; k++) {
        if (pq.empty() || pq2.empty()) break;
        curans -= pq2.top();
        pq2.pop();
        curans += pq.top();
        pq.pop();
        ans = max(ans, curans);
      }
    }
  }
  cout << ans;
}
