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

int n, k;
int a[100010];
long long int p[100010];
long long int m[100010];

int main() {

	cin >> n >> k;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		p[i] = p[i-1] + a[i];
		m[i] = m[i-1];
		if (a[i] > 0) m[i] += a[i];
	}
	
	long long int maxi = 0;
	for (int i = k; i <= n; i ++) {
		long long int tren = m[n] - m[i];
		tren += m[i-k];
		long long int zbr = p[i] - p[i-k];
		tren = max(tren, tren+zbr);
		
		maxi = max(maxi, tren);
	}

	cout << maxi;

	return 0;
}
