#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
  int n, k; cin >> n >> k;

  ll a[n+1], c[n+1], cp[n+1], sum = 0;
  c[0] = 0; cp[0] = 0;
  for(int i=1; i<=n; i++) {
    cin >> a[i];

    c[i] = c[i-1] + a[i];
    cp[i] = cp[i-1];
    if(a[i] > 0) {
      sum += a[i];
      cp[i] += a[i];
    }
  }

  ll ans = 0;
  for(int i=1; i + k <= n + 1; i++){
    ans = max(ans, sum - (cp[i+k-1]-cp[i-1]));
    ans = max(ans, sum - (cp[i+k-1]-cp[i-1]) + (c[i+k-1]-c[i-1]));
  }

  cout << ans << endl;
  
  return 0;
}
