#include <bits/stdc++.h>
using namespace std;
const int N = 2e2;
int n, k, a[N], b[N];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  int ans = -1e9;
  for (int l = 0; l < n; l++) {
    for (int r = l; r < n; r++) {
      int sum = 0;
      for (int i = 0; i < n; i++) {
        a[i] = b[i];
      }
      for (int i = l; i <= r; i++) {
        sum += a[i];
      }
      for (int ll = 0; ll < k; ll++) {
        int maxv = -20000;
        int mino = 20000;
        int posv = 0;
        int poso = 0;
        for (int kk = 0; kk < n; kk++) {
          if (kk < l || kk > r) {
            if (a[kk] > maxv) {
              maxv = a[kk];
              posv = kk;
            }
          } else {
            if (a[kk] < mino) {
              mino = a[kk];
              poso = kk;
            }
          }
        }
        if (maxv > mino) {
          sum = sum - mino + maxv;
          int x = a[poso];
          a[poso] = a[posv];
          a[posv] = x;
        }
      }
      if (sum > ans) ans = sum;
    }
  }
  cout << ans;
  return 0;
}
