#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() {
  ans.resize(N - K + 1, 0);
  for (int i = 0; i < (N - K + 1); i++) {
    for (int j = 0; j < (K); j++) {
      ans[i] += as[i + j];
    }
  }
  int index1 = -1;
  int res1 = 0;
  for (int i = 0; i < (ans.size()); i++) {
    if (ans[i] > res1) {
      res1 = ans[i];
      index1 = i;
    }
  }
  if (index1 != -1) {
    for (int i = 0; i < (index1); i++) {
      res1 += max(0, as[i]);
    }
    for (int i = index1 + K; i < (as.size()); i++) {
      res1 += max(0, as[i]);
    }
  }
  int index2 = -1;
  int min_v = INF;
  for (int i = 0; i < (ans.size()); i++) {
    if (ans[i] < min_v) {
      min_v = ans[i];
      index2 = i;
    }
  }
  int res2 = 0;
  if (index2 != -1) {
    for (int i = 0; i < (index2); i++) {
      res2 += max(0, as[i]);
    }
    for (int i = index2 + K; i < (as.size()); i++) {
      res2 += max(0, as[i]);
    }
  }
  return max(res1, res2);
}
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;
}
