#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, t, n, k;
  cin >> n >> k;
  vector<int> v(n + 5), b(n + 5), temp(n + 5);
  for (__typeof(0) i = 0; i <= n - 1; i++) {
    cin >> v[i];
    b[i] = v[i];
  }
  sort(b.begin(), b.begin() + n);
  int ans = INT_MIN;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      int a = 0;
      for (int z = i; z <= j; z++) {
        temp[a] = v[z];
        a++;
      }
      sort(temp.begin(), temp.begin() + a);
      int _k = min(k, a), p = a - 1, l = 0;
      int m = n - 1;
      while (p >= 0 && l < _k) {
        if (temp[p] < b[m]) {
          temp[l] = b[m];
          l++;
          m--;
        } else {
          p--;
          m--;
        }
      }
      int tem = 0;
      for (int g = 0; g < a; g++) tem += temp[g];
      ans = max(ans, tem);
    }
  }
  cout << ans << '\n';
  return 0;
}
