#include <bits/stdc++.h>
using namespace std;
int a[201];
int main() {
  ios_base::sync_with_stdio(0);
  std::vector<pair<int, int> > v;
  int n, k;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    int t;
    cin >> t;
    a[i] = t;
    v.push_back(make_pair(t, i));
  }
  sort(v.begin(), v.end());
  int msum = -999999999;
  int csum = 0;
  vector<int> temp;
  for (long long l = 0; l < n; l++) {
    int sz = 0;
    for (long long r = l; r < n; r++) {
      temp.clear();
      for (long long z = l; z < r + 1; z++) {
        temp.push_back(a[z]);
      }
      sz++;
      sort(temp.begin(), temp.end());
      int cur = 0;
      for (int i = n - 1; i >= 0; i--) {
        if (cur == k || cur == sz) {
          break;
        }
        pair<int, int> fu = v[i];
        if (fu.second < l || fu.second > r) {
          if (fu.first > temp[cur]) {
            temp[cur] = fu.first;
          } else {
            break;
          }
          cur++;
        }
      }
      csum = 0;
      for (long long i = 0; i < sz; i++) {
        csum += temp[i];
      }
      if (csum > msum) {
        msum = csum;
      }
    }
  }
  cout << msum << endl;
  return 0;
}
