#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  long n,k,a[100000],b[100000]={},suma[100001]={},sumb[100001]={},ans=0;
  scanf("%ld %ld",&n,&k);
  for(long i=0;i<n;i++){
    scanf("%ld",&a[i]);
    if(a[i]>0)
      b[i]=a[i];
    suma[i+1]=suma[i]+a[i];
    sumb[i+1]=sumb[i]+b[i];
  }
  for(int i=0;i+k<=n;i++){
    ans=max(ans,sumb[i]-suma[i]+suma[i+k]-sumb[i+k]+sumb[n]);
    ans=max(ans,sumb[i]-sumb[i+k]+sumb[n]);
  }
  printf("%ld\n",ans);
}