#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	int n, k;
	cin >> n >> k;
	vector<long long> a(n + 1), b(n + 1);
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a[i + 1] = a[i] + x;
		b[i + 1] = b[i] + max(0, x);
	}
	long long ans = -1e18;
	for(int i = 0; i < n + 1 - k; i++) {
		long long tmp = b[n] - (b[i + k] - b[i]);
		tmp += max(0LL, a[i + k] - a[i]);
		ans = max(tmp, ans);
	}
	cout << ans << endl;
	return 0;	
}