#include <bits/stdc++.h>
using namespace std;
int n;
int a[300] = {0};
int solve(int l, int r, int k) {
  vector<long long> out, in;
  out.empty();
  in.empty();
  for (int i = 0; i < n; i++)
    if (i < l || i > r) out.push_back(a[i]);
  for (int i = l; i <= r; i++) in.push_back(a[i]);
  sort(out.begin(), out.end());
  sort(in.begin(), in.end());
  int t = 0;
  for (int i = out.size() - 1; i >= 0 && k > t && t < in.size(); i--) {
    if (in[t] < out[i]) {
      in[t] = out[i];
      t++;
    } else
      break;
  }
  int sum = 0;
  for (int i = 0; i < in.size(); i++) sum += in[i];
  return sum;
}
int main() {
  int k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  int ans = a[0];
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++) ans = max(ans, solve(i, j, k));
  cout << ans;
}
