#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N,K; cin >> N >> K;
	vector<LL> a(N),s(N+1),p(N+1);
	s[0] = p[0] = 0;
	repp(i,0,N){
		cin >> a[i];
		s[i+1] = s[i]+a[i];
		p[i+1] = p[i]+max<LL>(0,a[i]);
	}
	LL ans = 0;
	repp(i,K,N+1){
		ans = max(ans,p[N]-p[i]+p[i-K]+max<LL>(0,s[i]-s[i-K]));
	}
	cout << ans << endl;
	return 0;
}
