#include <bits/stdc++.h>
using namespace std;
vector<int> a, b;
int k, n;
int solve(int l, int r) {
  int sum = 0, i, j, c;
  b = a;
  c = k;
  sort(b.begin() + l, b.begin() + r + 1);
  for (i = l; i <= r; i++) {
    if (c > 0) {
      for (j = 0; j < l; j++)
        if (b[j] > b[i]) swap(b[j], b[i]);
      for (j = r + 1; j < n; j++)
        if (b[j] > b[i]) swap(b[j], b[i]);
      c--;
    }
    sum += b[i];
  }
  return sum;
}
int main() {
  int i, j, ans;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) {
    int p;
    scanf("%d", &p);
    a.push_back(p);
  }
  ans = -1500;
  for (i = 0; i < n; i++)
    for (j = i; j < n; j++) ans = max(ans, solve(i, j));
  printf("%d\n", ans);
  return 0;
}
