#include <iostream>
using namespace std;
typedef long long ll;
ll s[100001],t[100001];
int main(void){
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        s[i+1]=s[i]+a;
        t[i+1]=max(0LL,a);
    }
    for(int i=0;i<n;i++){
        t[i+1]+=t[i];
    }
    ll ans=-(1LL<<60);
    for(int i=0;i<n-k+1;i++){
        ans=max(ans,max(0LL,s[i+k]-s[i])+t[i]+t[n]-t[i+k]);
    }
    cout<<ans<<endl;
}
