#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n, a[210], sum[211], b[211], c[211], K;
int main() {
  cin >> n >> K;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
  }
  int ans = -int(2e9);
  for (int i = 1; i <= n; ++i)
    for (int j = i; j <= n; ++j) {
      int p = 1, second = 1;
      for (int k = 1; k <= n; ++k)
        if (k >= i && k <= j)
          b[p++] = a[k];
        else
          c[second++] = a[k];
      sort(c + 1, c + second);
      reverse(c + 1, c + second);
      sort(b + 1, b + p);
      int res = sum[j] - sum[i - 1];
      ans = max(ans, res);
      int t1 = 1, t2 = 1;
      for (int q = 0; q < K; ++q) {
        int x = -int(2e9), y = -int(2e9);
        if (t1 < second) x = c[t1++];
        if (t2 < p) y = b[t2++];
        if (y == -int(2e9)) break;
        if (x > y)
          res += (x - y);
        else if (y < 0 && j - i + 1 > 1)
          res += y;
        ans = max(ans, res);
      }
    }
  printf("%d", ans);
  return 0;
}
