#include <bits/stdc++.h>
using namespace std;
int a[220];
int n, k;
int b[220], c[220];
bool cmp(int a, int b) { return a > b; }
int cal(int l, int r) {
  int i, j, s1 = 0, s2 = 0;
  vector<int> b, c;
  for (i = 0; i < n; i++) {
    if (i < l || i > r)
      b.push_back(a[i]);
    else
      c.push_back(a[i]);
  }
  sort(b.rbegin(), b.rend());
  sort(c.begin(), c.end());
  s1 = b.size(), s2 = c.size();
  for (i = 0; i < k && i < s1 && i < s2; i++) {
    if (b[i] > c[i]) swap(b[i], c[i]);
  }
  int ans = 0;
  for (i = 0; i < s2; i++) ans += c[i];
  return ans;
}
int main() {
  int i, j;
  scanf("%d%d", &n, &k);
  int ans = -1000000;
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < n; i++)
    for (j = i; j < n; j++) ans = max(ans, cal(i, j));
  printf("%d\n", ans);
  return 0;
}
