#include <bits/stdc++.h>
int A[201];
int X[201], xc;
int Y[201], yc;
int main() {
  int N, K;
  int i, j, k;
  int Max, first = 0, S;
  scanf("%d %d", &N, &K);
  for (i = 1; i <= N; i++) scanf("%d", &A[i]);
  for (i = 1; i <= N; i++) {
    for (j = i; j <= N; j++) {
      xc = yc = S = 0;
      for (k = 1; k <= N; k++) {
        if (i <= k && k <= j)
          X[++xc] = A[k], S += A[k];
        else
          Y[++yc] = A[k];
      }
      std::sort(X + 1, X + 1 + xc);
      std::sort(Y + 1, Y + 1 + yc);
      if (!first)
        first = 1, Max = S;
      else if (Max < S)
        Max = S;
      for (k = 1; k <= K; k++) {
        if (yc - k + 1 < 1) break;
        if (k > xc) break;
        if (Y[yc - k + 1] <= X[k]) continue;
        S = S - X[k] + Y[yc - k + 1];
        if (Max < S) Max = S;
      }
    }
  }
  printf("%d", Max);
}
