#include <bits/stdc++.h>
using namespace std;
int a[205];
int main() {
  int n, k;
  while (~scanf("%d%d", &n, &k)) {
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
    int MAXSUM = -0x3f3f3f;
    for (int l = 0; l < n; ++l)
      for (int r = l; r < n; ++r) {
        priority_queue<int> Q;
        priority_queue<int, vector<int>, greater<int> > P;
        int sum = 0;
        for (int i = 0; i < n; ++i) {
          if (i < l || i > r)
            Q.push(a[i]);
          else {
            P.push(a[i]);
            sum += a[i];
          }
        }
        for (int i = 0; i < min(k, n - (r - l + 1)); ++i) {
          int MAX = Q.top();
          int MIN = P.top();
          sum = sum + MAX - MIN;
          Q.pop();
          P.pop();
          P.push(MAX);
          Q.push(MIN);
        }
        if (sum > MAXSUM) MAXSUM = sum;
        while (!P.empty()) P.pop();
        while (!Q.empty()) Q.pop();
      }
    printf("%d\n", MAXSUM);
  }
  return 0;
}
