#include <bits/stdc++.h>
using namespace std;
int a[500];
int main() {
  int n, T;
  scanf("%d %d", &n, &T);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int maxs = -0x3f3f3f3f;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      priority_queue<int, vector<int>, less<int> > out;
      priority_queue<int, vector<int>, greater<int> > in;
      for (int k = 1; k <= n; k++) {
        if (k >= i && k <= j) {
          in.push(a[k]);
        } else {
          out.push(a[k]);
        }
      }
      int temp = T;
      while (temp--) {
        if (out.size() == 0 || in.size() == 0) continue;
        int u = out.top();
        int v = in.top();
        if (u > v) {
          in.pop();
          out.pop();
          out.push(v);
          in.push(u);
        }
      }
      int sum = 0;
      while (!in.empty()) {
        int u = in.top();
        sum += u;
        in.pop();
      }
      maxs = max(maxs, sum);
    }
  }
  printf("%d\n", maxs);
}
