#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;

const int MAX_N=1e5;

int N,K;
int A[MAX_N];

ll sum1[MAX_N+1],sum2[MAX_N+1];

int main(){
	cin>>N>>K;
	REP(i,N){
		cin>>A[i];
	}
	REP(i,N){
		sum1[i+1]=sum1[i]+A[i];
		sum2[i+1]=sum2[i]+max(A[i],0);
	}
	ll ans=0;
	REP(i,N-K+1){
		ans=max(ans,max(sum1[i+K]-sum1[i],0LL)+sum2[i]+sum2[N]-sum2[i+K]);
	}
	cout<<ans<<endl;
	return 0;
}
