#include <bits/stdc++.h>
using namespace std;
int a[205];
int main() {
  int n, mm;
  while (~scanf("%d%d", &n, &mm)) {
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    int ans = -10000000;
    for (int i = 1; i <= n; i++) {
      for (int j = i; j <= n; j++) {
        priority_queue<int, vector<int>, greater<int> > q1;
        priority_queue<int> q2;
        int sum = 0;
        for (int k = 1; k <= n; k++) {
          if (k >= i && k <= j) {
            sum += a[k];
            q1.push(a[k]);
          } else
            q2.push(a[k]);
        }
        int m = mm;
        while (m && (!q2.empty()) && (!q1.empty()) && (q2.top() > q1.top())) {
          m--;
          sum -= q1.top();
          sum += q2.top();
          q1.pop();
          q2.pop();
        }
        ans = max(ans, sum);
      }
    }
    printf("%d\n", ans);
  }
}
