#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("trapv")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")
const int N = 1e5 + 40;
const int MAXK = 12;
const long long int INF = 1000000000000000000;
const int RANDOM =
    chrono::high_resolution_clock::now().time_since_epoch().count();
long long int expo_pow(long long int x, long long int y) {
  if (y == 0) return 1;
  y = y % ((1000000007) - 1);
  x %= (1000000007);
  if (y == 0) y = (1000000007) - 1;
  long long int res = 1;
  while (y) {
    if (y & 1) res = (res * x) % (1000000007);
    x = (x * x) % (1000000007);
    y >>= 1;
  }
  return res;
}
long long int modInverse(long long int a, long long int m = (1000000007)) {
  return expo_pow(a, m - 2);
}
void solve() {
  int n, k;
  cin >> n >> k;
  int a[n + 2];
  for (int i = (1); i < (n + 1); i++) {
    cin >> a[i];
  }
  int ans = -1e9;
  for (int i = (1); i < (n + 1); i++) {
    for (int j = (i); j < (n + 1); j++) {
      cout.flush();
      multiset<int> second, oth;
      for (int k = (i); k < (j + 1); k++) second.insert(a[k]);
      for (int k = (1); k < (n + 1); k++) {
        if (k >= i && k <= j)
          continue;
        else {
          oth.insert(-a[k]);
        }
      }
      cout.flush();
      for (int l = (1); l < (k + 1); l++) {
        if (oth.empty() || second.empty()) break;
        int cur1 = *second.begin();
        int cur2 = -*oth.begin();
        if (cur2 > cur1) {
          second.erase(second.find(cur1));
          oth.erase(oth.find(-cur2));
          second.insert(cur2);
        } else
          break;
      }
      int ta = 0;
      while (second.size()) {
        ta += *second.begin();
        second.erase(second.find(*second.begin()));
      }
      ans = max(ans, ta);
    }
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  while (T--) {
    solve();
  }
}
