#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed 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] + (x > 0 ? x : 0);
	}
	long long ans = 0;
	for (int i = 1; i <= n - k + 1; i++) {
		long long cur = b[i - 1] + b[n] - b[i + k - 1];
		cur += max(0LL, a[i + k - 1] - a[i - 1]);
		ans = max(cur, ans);
	}
	cout << ans << endl;
	return 0;	
}