#include <bits/stdc++.h>
using namespace std;
int Set(int N, int pos) { return N = N | (1 << pos); }
int reset(int N, int pos) { return N = N & ~(1 << pos); }
bool check(int N, int pos) { return (bool)(N & (1 << pos)); }
void CI(int &_x) { scanf("%d", &_x); }
void CO(int &_x) { cout << _x; }
template <typename T>
void getarray(T a[], int n) {
  for (int i = 0; i < n; i++) cin >> a[i];
}
template <typename T>
void printarray(T a[], int n) {
  for (int i = 0; i < n - 1; i++) cout << a[i] << " ";
  cout << a[n - 1] << endl;
}
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
int dr8[8] = {1, -1, 0, 0, 1, -1, -1, 1};
int dc8[8] = {0, 0, -1, 1, 1, 1, -1, -1};
int dr4[4] = {0, 0, 1, -1};
int dc4[4] = {-1, 1, 0, 0};
int kn8r[8] = {1, 2, 2, 1, -1, -2, -2, -1};
int kn8c[8] = {2, 1, -1, -2, -2, -1, 1, 2};
bool taken[205] = {0};
int sz;
int main() {
  vector<int> V;
  int n, kount;
  cin >> n >> kount;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    V.push_back(temp);
  }
  int ans = -(1 << 30);
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++) {
      vector<int> A, B;
      for (int k = 0; k < n; k++)
        if (k >= i && k <= j)
          A.push_back(V[k]);
        else
          B.push_back(V[k]);
      sort(A.begin(), A.end());
      sort(B.begin(), B.end());
      int sz = B.size() - 1;
      for (int k = 0; k < A.size() && k < kount && sz >= 0; k++) {
        if (A[k] < B[sz]) {
          swap(A[k], B[sz]);
          sz--;
        }
      }
      int sum = 0;
      for (int k = 0; k < A.size(); k++) {
        sum += A[k];
      }
      ans = max(ans, sum);
    }
  cout << ans << "\n";
  return 0;
}
