#include <bits/stdc++.h>
using namespace std;
const int inf = 100000000;
int a[201], k, n, ans = -inf;
bool cmp(int x, int y) { return x > y; }
int solve(int x, int y) {
  vector<int> A, B;
  int cur1 = 0, cur2 = 0, sum = 0, cntk = 0;
  for (int i = 1; i <= n; i++)
    if (i >= x && i <= y)
      A.push_back(a[i]);
    else
      B.push_back(a[i]);
  sort(A.begin(), A.end());
  sort(B.begin(), B.end(), cmp);
  while (cntk < k && cur1 < A.size() && cur2 < B.size()) {
    if (A[cur1] < B[cur2]) {
      swap(A[cur1], B[cur2]);
      cur1++, cur2++;
      cntk++;
    } else
      break;
  }
  for (int i = 0; i < A.size(); i++) sum += A[i];
  return sum;
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++) ans = max(solve(i, j), ans);
  cout << ans;
  return 0;
}
