#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
	int n, k;
	long long ans = 0;
	cin >> n >> k;
	vector<long long> a(n + 1), b(n + 1);
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		b[i] = b[i - 1] + max(a[i], 0LL);
		a[i] = a[i - 1] + a[i];
	}
	for(int i = k; i <= n; i++){
		long long t = max(a[i] - a[i - k], 0LL);
		ans = max(ans, b[i - k] + b[n] - b[i] + t);
	}
	cout << ans << endl;
	return 0;
}