#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	vector<long long> A(N), S(N + 1), PS(N + 1);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		S[i + 1] = S[i] + A[i];
		PS[i + 1] = PS[i] + (A[i] > 0 ? A[i] : 0);
	}
	long long ans = -(1LL << 60);
	for (int i = 0; i <= N - K; ++i) {
		long long mid = max((long long)(0), S[i + K] - S[i]);
		long long sum = mid + PS[i] + (PS[N] - PS[i + K]);
		ans = max(ans, sum);
	}
	cout << ans << endl;
	return 0;
}