#include <bits/stdc++.h>
using namespace std;
const int N = 202;
int n, K, a[N];
int memo[N][N][N][2][2];
int go(int i, int taken, int removed, bool start, bool end) {
  if (i == n) {
    if (taken == removed && taken <= K) return 0;
    return -1e9;
  }
  int &ret = memo[i][taken][removed][start][end];
  if (ret != -1) return ret;
  ret = -1e9;
  if (!start) {
    ret = go(i + 1, taken, removed, false, false);
    ret = max(ret, go(i + 1, taken + 1, removed, false, false) + a[i]);
  }
  if (!end) {
    if (start) ret = max(ret, go(i, taken, removed, true, true));
    ret = max(ret, go(i + 1, taken, removed, true, false) + a[i]);
    ret = max(ret, go(i + 1, taken, removed + 1, true, false));
  } else {
    ret = go(i + 1, taken, removed, true, true);
    ret = max(ret, go(i + 1, taken + 1, removed, true, true) + a[i]);
  }
  return ret;
}
int main() {
  scanf("%d %d", &n, &K);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  memset(memo, -1, sizeof memo);
  int result = go(0, 0, 0, false, false);
  if (result)
    printf("%d\n", result);
  else
    printf("%d\n", *max_element(a, a + n));
  return 0;
}
