#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[210];
pair<int, int> s[210];
int n, k, tsum, o, sum[210];
int ans;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
    s[i].first = a[i].first;
    s[i].second = a[i].second;
    sum[i] = a[i].first;
    if (i) sum[i] += sum[i - 1];
  }
  sort(s, s + n);
  int t, p, h, other, left;
  reverse(s, s + n);
  ans = sum[n - 1];
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      tsum = sum[j];
      if (i) tsum -= sum[i - 1];
      o = j - i + 1;
      left = j - i + 1;
      t = p = 0;
      other = 0;
      for (int l = 0; l < n; l++) {
        if (s[l].second >= i && s[l].second <= j)
          t++;
        else {
          if (t == o) break;
          if (other >= o - t || other >= k) break;
          other++;
          tsum += s[l].first;
        }
      }
      for (int l = n - 1; l >= 0; l--) {
        if (!other) break;
        if (s[l].second >= i && s[l].second <= j) {
          other--;
          tsum -= s[l].first;
        }
      }
      ans = max(ans, tsum);
    }
  }
  cout << ans << endl;
}
