#include <bits/stdc++.h>
using namespace std;
const int MX = 300;
long long int n, k, a[MX], ans;
vector<long long int> e, v;
void input() {
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  ans = a[1];
}
void solve() {
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      long long int sum = 0;
      v.clear(), e.clear();
      for (int s = 1; s <= n; ++s) {
        if (s < i || s > j)
          v.push_back(a[s]);
        else {
          e.push_back(a[s]);
          sum += a[s];
        }
      }
      sort(e.begin(), e.end());
      sort(v.begin(), v.end());
      reverse(v.begin(), v.end());
      long long int x = min(v.size(), e.size());
      x = min(k, x);
      long long int an1 = 0, an2 = 0;
      long long int f = sum;
      for (int s = 0; s < x; ++s) {
        an1 += v[s], an2 += e[s];
        f = max(f, sum - an2 + an1);
      }
      sum = max(sum, f);
      ans = max(ans, sum);
    }
  }
  cout << ans << endl;
}
int main() {
  input();
  solve();
}
