#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const string LN = "\n";
const double eps = 1e-9;
const double pi = acos(-1.0);
const int INF = (int)2e9 + 7;
const long long LINF = (long long)9e18 + 7;
const long long P = 353251;
const long long P1 = 239017;
const long long P2 = 239017;
const long long MOD = 1e9 + 7;
const long long MOD2 = 1e9 + 9;
int n, k;
int a[207];
int ans = -INF;
multiset<int> se, all;
int get(multiset<int> a, multiset<int> b) {
  int was = 0;
  while (1) {
    if (was == k) break;
    was++;
    if (a.size() > 0 && b.size() > 0 && *a.begin() < *(--b.end())) {
      a.erase(a.begin());
      a.insert(*(--b.end()));
      b.erase(--b.end());
    } else
      break;
  }
  int sum = 0;
  for (auto t : a) sum += t;
  return sum;
}
const bool is_testing = 0;
int main() {
  srand('D' + 'E' + 'N' + 'I' + 'S' + 'S' + 'O' + 'N');
  ios_base::sync_with_stdio(0);
  if (is_testing) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  } else {
  }
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    all.insert(a[i]);
  }
  for (int l = 0; l < n; l++) {
    se = all;
    multiset<int> now;
    for (int r = l; r < n; r++) {
      now.insert(a[r]);
      se.erase(se.find(a[r]));
      ans = max(ans, get(now, se));
    }
  }
  cout << ans;
  if (is_testing) {
    cout << LN << 1.0 * clock() / CLOCKS_PER_SEC << LN;
  }
}
