#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, k, res = -9000000000000000000;
  cin >> n >> k;
  long long t[n];
  vector<long long> v, all;
  for (long long i = 0; i < n; i++) cin >> t[i], all.push_back(t[i]);
  sort(all.rbegin(), all.rend());
  for (long long i = 0; i < n; i++) {
    for (long long j = i; j < n; j++) {
      v.clear();
      for (long long l = i; l <= j; l++) {
        v.push_back(t[l]);
        sort(v.rbegin(), v.rend());
      }
      long long nb = k, c = 0, curr = 0, sz = v.size();
      for (long long l = 0; curr < sz && l < (j - i + 1); l++) {
        if (v[curr] == all[l]) {
          c += v[curr];
          curr++;
        } else if (nb) {
          c += all[l];
          nb--;
        } else {
          c += v[curr];
          curr++;
        }
      }
      res = max(res, c);
    }
  }
  cout << res;
}
