#include <bits/stdc++.h>
using namespace std;
const int DX[] = {1, 0, -1, 0}, DY[] = {0, -1, 0, 1};
const int INF = 0x3f3f3f3f;
int N, K;
vector<int> as;
vector<int> ans;
int solve() {
  for (int i = 0; i < (N - K + 1); i++) {
    int res1 = 0, res2 = 0;
    for (int j = 0; j < (K); j++) {
      res1 += as[i + j];
    }
    for (int j = 0; j < (i); j++) {
      res1 += max(0, as[j]);
      res2 += max(0, as[j]);
    }
    for (int j = i + K; j < (as.size()); j++) {
      res1 += max(0, as[j]);
      res2 += max(0, as[j]);
    }
    ans.push_back(max(res1, res2));
  }
  return *max_element(ans.begin(), ans.end());
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> K;
  for (int i = 0; i < (N); i++) {
    int a;
    cin >> a;
    as.push_back(a);
  }
  cout << solve() << endl;
  return 0;
}
