#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 10);
  vector<int> rui(n + 10);
  vector<int> rui2(n + 10);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    rui[i] = rui[i - 1] + a[i];
    if (a[i] > 0)
      rui2[i] = rui2[i - 1] + a[i];
    else
      rui2[i] = rui2[i - 1];
  }
  int res = 0;
  for (int i = k; i <= n; i++) {
    int tmp = rui[i] - rui[i - k];
    if (tmp < 0) tmp = 0;
    tmp += rui2[i - k] + rui2[n] - rui2[i];
    res = max(tmp, res);
  }
  cout << res << endl;
}
