#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> b, w;
  long long bcnt = 0, wcnt = 0;
  for (int i = 0; i < k; i++) {
    bcnt += max(0, a[i]);
    wcnt += min(0, a[i]);
  }
  b.push_back(bcnt);
  w.push_back(wcnt);
  for (int i = k; i < n; i++) {
    bcnt += max(0, a[i]) - max(0, a[i - k]);
    b.push_back(bcnt);
    wcnt += min(0, a[i]) - min(0, a[i - k]);
    w.push_back(wcnt);
  }
  bcnt = 0;
  for (int i = 0; i < n; i++) bcnt += max(0, a[i]);
  long long ret = -1e15;
  for (int i = 0; i < b.size(); i++) {
    ret = max(ret, max(bcnt - b[i], bcnt + w[i]));
  }
  cout << ret << endl;
  return 0;
}
