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

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	vector<ll> b(n + 1), c(n + 1);
	for(int i = 0; i < n; ++i){ b[i + 1] = b[i] + a[i]; }
	for(int i = 0; i < n; ++i){ c[i + 1] = c[i] + max(0ll, a[i]); }
	ll answer = 0;
	for(int i = 0; i + k <= n; ++i){
		answer = max(answer, c[i] + max(0ll, b[i + k] - b[i]) + (c[n] - c[i + k]));
	}
	cout << answer << endl;
	return 0;
}

