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

const int N = 100005;

int n, k;
int a[N];
long long f[N], s[N];
long long ans;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	for (int i = 1; i <= n; ++i) {
		f[i] = f[i - 1] + max(0, a[i]);
		s[i] = s[i - 1] + a[i];
	}

	for (int i = k; i <= n; ++i) {
		long long add = max(0LL, s[i] - s[i - k]);
		ans = max(ans, add + f[i - k] + f[n] - f[i]);
	}
	cout << ans << endl;
}