#include <iostream>
#include <vector>
using namespace std;

typedef long long int ll;

int main(void){
    // Here your code !
    int n,k;
    cin >> n >> k;
    
    vector<ll> a(n+10);
    vector<ll> rui(n+10);
    vector<ll> 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];
    }
    
    
    ll 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;
    
    
}
