#include <iostream>
#include <vector>

using namespace std;

int main(){
	int N, K;
	while(cin >> N >> K){
		vector<long long> A(N), PS(N+1, 0), S(N+1, 0);
		for(int i=0;i<N;i++) cin >> A[i];
		for(int i=0;i<N;i++){
			PS[i+1] = PS[i] + max(0LL, A[i]);
			S[i+1] = S[i] + A[i];
		}
		long long res = 0;
		for(int i=0;i+K<=N;i++){
			res = max(res, PS[i] + PS[N] - PS[i+K] + max(0LL, S[i+K]-S[i]));
		}
		cout << res << endl;
	}
}
