#include <bits/stdc++.h>
using namespace std;
int a[205];
vector<int> in, out;
int main() {
  int n, k;
  int sol = -999999;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++) {
      int sum = 0;
      in.clear();
      out.clear();
      for (int l = 0; l < n; l++) {
        if (i <= l && l <= j)
          in.push_back(a[l]);
        else
          out.push_back(a[l]);
      }
      sort(in.begin(), in.end());
      sort(out.begin(), out.end());
      reverse(out.begin(), out.end());
      for (int l = 0; l < in.size(); l++) {
        if (l < k && l < out.size())
          sum += max(in[l], out[l]);
        else
          sum += in[l];
      }
      if (sum > sol) sol = sum;
    }
  printf("%d\n", sol);
  return 0;
}
