#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long
signed main() {
	int n, k; cin >> n >> k;
	int a[123456], sum = 0, sum1 = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i < k)sum += a[i];
		else sum1 += max((int)0, a[i]);
	}
	int ans = max(sum, (int)0) + sum1;
	for (int i = 0; i < n - k; i++) {
		sum -= a[i];
		sum1 += max((int)0, a[i]);
		sum1 -= max((int)0, a[i + k]);
		sum += a[i + k];
		ans = max(ans, max(sum, (int)0) + sum1);
	}
	cout << ans << endl;}