#include <bits/stdc++.h>
using namespace std;
int a[300], s[300][300], b[300];
int main() {
  int N, K;
  while (cin >> N >> K) {
    for (int i = 1; i <= N; ++i) cin >> a[i];
    for (int i = 1; i <= N; ++i) {
      s[i][i] = a[i];
      for (int j = i + 1; j <= N; ++j) {
        s[i][j] = s[i][j - 1] + a[j];
      }
    }
    int ans = s[1][N];
    for (int i = 1; i <= N; ++i)
      for (int j = i; j <= N; ++j) {
        if (i == 1 && j == N) continue;
        priority_queue<int, vector<int>, greater<int> > pa;
        priority_queue<int> pb;
        for (int k = 1; k <= N; ++k)
          if (k < i || k > j)
            pb.push(a[k]);
          else
            pa.push(a[k]);
        for (int k = 0; k < K; ++k) {
          if (pb.top() > pa.top()) {
            int _b = pb.top();
            pb.pop();
            int _a = pa.top();
            pa.pop();
            pa.push(_b), pb.push(_a);
          }
        }
        int cur = 0;
        while (!pa.empty()) {
          cur += pa.top();
          pa.pop();
        }
        ans = max(ans, cur);
      }
    cout << ans << endl;
  }
  return 0;
}
