#include <bits/stdc++.h>
using namespace std;
const int NMAX = 203;
int a[NMAX], inside[NMAX], outside[NMAX];
int main() {
  cin.sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int sol = -(1 << 30), sum = 0, st, dr, insize, outsize;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      st = i;
      dr = j;
      sum = 0, insize = 0, outsize = 0;
      for (int ind = st; ind <= dr; ind++) {
        sum += a[ind];
        inside[++insize] = a[ind];
      }
      for (int ind = 1; ind < st; ind++) {
        outside[++outsize] = a[ind];
      }
      for (int ind = dr + 1; ind <= n; ind++) {
        outside[++outsize] = a[ind];
      }
      sort(outside, outside + outsize + 1);
      sort(inside, inside + insize + 1);
      int insecv = 1;
      int sfarsit = outsize;
      for (int steps = 1; steps <= k && insecv <= insize && sfarsit; steps++) {
        if (inside[insecv] < outside[sfarsit]) {
          sum = sum - inside[insecv] + outside[sfarsit];
          insecv++, sfarsit--;
        } else
          break;
      }
      sol = max(sol, sum);
    }
  }
  cout << sol << "\n";
  return 0;
}
