#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    int n,K;cin>>n>>K;
    LL a[n];REP(i,n)cin>>a[i];

    LL sum[n+1];
    sum[0]=0;
    REP(i,n)sum[i+1]=sum[i]+a[i];

    LL plus[n+1];
    plus[0]=0;
    REP(i,n)plus[i+1]=plus[i]+(a[i]>0 ? a[i]: 0);

    LL ans=-10000000000LL;
    for(int i=0;i+K<=n;i++){
        ans = max(ans,max(sum[i+K]-sum[i],0LL)+ plus[n]-plus[i+K] + plus[i]-plus[0]);
    }
    cout<<ans<<endl;

    return 0;
}