#include <bits/stdc++.h>
using namespace std;
int arr[234], a1[234], a2[234], maxsum;
int main() {
  int n, k, sz1, sz2, itr1, itr2, temp;
  scanf("%d", &n);
  scanf("%d", &k);
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  maxsum = INT_MIN;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      sz1 = sz2 = 0;
      for (int l = i; l <= j; l++) a1[sz1++] = arr[l];
      for (int l = 0; l < i; l++) a2[sz2++] = arr[l];
      for (int l = j + 1; l < n; l++) a2[sz2++] = arr[l];
      sort(a1, a1 + sz1);
      sort(a2, a2 + sz2);
      reverse(a2, a2 + sz2);
      itr1 = itr2 = 0;
      temp = k;
      while (1) {
        if (itr2 == sz2) break;
        if (itr1 == sz1) break;
        if (temp == 0) break;
        if (a2[itr2] > a1[itr1]) {
          a1[itr1] = a2[itr2];
          itr1++;
          temp--;
        } else
          break;
        itr2++;
      }
      temp = 0;
      for (int l = 0; l < sz1; l++) temp += a1[l];
      if (temp == 41)
        cerr << "i"
             << ": " << i << " | "
             << "j"
             << ": " << j << " | "
             << "sz1"
             << ": " << sz1 << endl;
      ;
      maxsum = max(maxsum, temp);
    }
  }
  printf("%d\n", maxsum);
  return 0;
}
