#include<stdio.h>
#include<algorithm>
using namespace std;
int n, K;
long long S[101000], S2[101000], Res;
int main(){
    int i;
    scanf("%d%d",&n,&K);
    for(i=1;i<=n;i++){
        scanf("%lld",&S[i]);
        S2[i] = max(0ll,S[i]);
        S[i] += S[i-1];
        S2[i] += S2[i-1];
    }
    for(i=0;i<=n-K;i++){
        Res = max(Res,S2[i] + S2[n] - S2[i+K]);
        Res = max(Res,S2[i] + S2[n] - S2[i+K] + S[i+K] - S[i]);
    }
    printf("%lld\n",Res);
}