#include <bits/stdc++.h>
using namespace std;
int A[205];
int main() {
  int N, K;
  scanf("%d%d", &N, &K);
  for (int i = 0; i < N; i++) scanf("%d", &A[i]);
  int ans = A[0];
  for (int L = 0; L < N; L++)
    for (int R = L; R < N; R++) {
      vector<int> B, C;
      for (int i = 0; i < L; i++) B.push_back(A[i]);
      for (int i = R + 1; i < N; i++) B.push_back(A[i]);
      sort(B.begin(), B.end());
      for (int i = L; i <= R; i++) C.push_back(A[i]);
      sort(C.begin(), C.end());
      int indC = 0, indB = B.size() - 1, count = 0;
      while (count < K && indB >= 0 && indC < C.size()) {
        if (C[indC] < B[indB]) {
          C[indC] = B[indB];
          indC++;
          indB--;
          count++;
        } else {
          break;
        }
      }
      int temp = 0;
      for (int i = 0; i < C.size(); i++) temp += C[i];
      ans = max(ans, temp);
    }
  printf("%d\n", ans);
  return 0;
}
