#include <bits/stdc++.h>
using namespace std;
int arr[201];
int first[201];
int last[201];
int Mid[201];
int main() {
  int n, m, ans = -1000000000;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      int c1 = 0, c2 = 0;
      for (int k = 0; k < i; k++) {
        first[c1++] = arr[k];
      }
      for (int k = j + 1; k < n; k++) {
        first[c1++] = arr[k];
      }
      sort(first, first + c1);
      c1--;
      int sum = 0;
      for (int k = i; k <= j; k++) {
        Mid[c2++] = arr[k];
        sum += arr[k];
      }
      sort(Mid, Mid + c2);
      int o = m;
      int u = 0;
      while (true) {
        if (c1 < 0 || u >= c2 || o <= 0) break;
        o--;
        if (Mid[u] < first[c1]) {
          sum -= Mid[u++];
          sum += first[c1--];
        }
      }
      ans = max(ans, sum);
    }
  }
  cout << ans;
}
