#include<cstdio>
#include<iostream>
#define MN 100005
using namespace std;
int n,k;
long long a[MN],ans,s1[MN],s2[MN];
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        s1[i]=s1[i-1]+a[i];
        s2[i]=s2[i-1];
        if(a[i]>0) s2[i]+=a[i];
    }
    for(int i=k;i<=n;i++){
        long long t1=s1[i]-s1[i-k],t2=s2[i-k]+s2[n]-s2[i];
        if(t1>0) t2+=t1;
        ans=max(ans,t2);
    }
    printf("%lld",ans);
    return 0;
}