#include <bits/stdc++.h>
using namespace std;
int a[100001];
int pref[100001];
int suff[100001];
int d[100001];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    d[i] = d[i - 1] + a[i];
    pref[i] = pref[i - 1] + max(0, a[i]);
  }
  for (int i = n; i >= 1; i--) {
    suff[i] = suff[i + 1] + max(0, a[i]);
  }
  int ans = 0;
  for (int l = 1; l + k - 1 <= n; l++) {
    int r = l + k - 1;
    int jkl = d[r] - d[l - 1];
    int cur = max(0, jkl);
    cur += pref[l - 1];
    cur += suff[r + 1];
    ans = max(ans, cur);
  }
  cout << ans;
  return 0;
}
