#include <bits/stdc++.h>
double const EPS = 3e-8;
using namespace std;
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
template <class T>
inline bool read(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c < '0' || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
const int MX = 205;
int inp[MX];
int main() {
  int n, NumofSwap;
  n = ({
    int a;
    read(a);
    a;
  }),
  NumofSwap = ({
    int a;
    read(a);
    a;
  });
  int i, j, l, r;
  for (int i = 0; i < n; i++)
    inp[i] = ({
      int a;
      read(a);
      a;
    });
  int ans = -(1 << 29);
  for (l = 0; l < n; l++) {
    for (r = l; r < n; r++) {
      vector<int> In, Out;
      for (i = 0; i < n; i++) {
        if (i >= l && i <= r)
          In.push_back(inp[i]);
        else
          Out.push_back(inp[i]);
      }
      sort(In.begin(), In.end());
      sort(Out.begin(), Out.end());
      int sum = 0;
      for (i = 0; i < In.size(); i++) {
        sum += In[i];
      }
      ans = max(ans, sum);
      for (i = 0; i < min(NumofSwap, (int)min(In.size(), Out.size())); i++) {
        sum -= In[i];
        sum += Out[Out.size() - 1 - i];
        ans = max(ans, sum);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
