#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
#define eprintf(...) fprintf(stderr,__VA_ARGS__)

const int N=int(1e5)+5;
const ll inf=ll(1e18)+7;

int n,k;
int a[N];
ll sum[N],pre[N];

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		sum[i]=sum[i-1]+a[i];
		pre[i]=pre[i-1]+max(a[i],0);
	}
	ll ans=-inf;
	for(int i=0;i<=n-k;i++){
		ans=max(ans,max(0LL,sum[i+k]-sum[i])+pre[i]+(pre[n]-pre[i+k]));
	}
	printf("%lld\n",ans);
}