#include <bits/stdc++.h>
using namespace std;
int n, k, B[201];
pair<int, int> a[201];
bool comp(pair<int, int> x, pair<int, int> y) { return x.first > y.first; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  long long res = 0;
  for (int i = 1, b = (n); i <= b; ++i) {
    cin >> a[i].first;
    a[i].second = i;
    res += a[i].first;
    B[i] = a[i].first;
  }
  sort(a + 1, a + 1 + n, comp);
  for (int lo = 1, b = (n); lo <= b; ++lo)
    for (int hi = lo, b = (n); hi <= b; ++hi) {
      vector<int> tmp;
      long long cur = 0;
      for (int i = lo, b = (hi); i <= b; ++i) {
        tmp.push_back(B[i]);
        cur += B[i];
      }
      sort(tmp.begin(), tmp.end());
      int i = 0, j = 1;
      int _k = k;
      while (_k > 0) {
        while (j <= n && a[j].second <= hi && a[j].second >= lo) ++j;
        if (i <= ((int)tmp.size()) - 1 && j <= n && a[j].first > tmp[i]) {
          cur = cur - tmp[i] + a[j].first;
          ++i;
          ++j;
          --_k;
        } else
          break;
      }
      if (res < cur) {
        res = cur;
      }
    }
  cout << res << endl;
  return 0;
}
