#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#define ll long long
using namespace std;

ll d[100001],f[100001];//d 全て
signed main() {
	int a, b; cin >> a >> b;
	ll s = 0;
	for (int c = 0; c < a; c++) {
		int e;
		cin >> e;
		f[c + 1] = f[c] + max(0, e);
		d[c + 1] = d[c] + e;
	}
	ll MAX = 0;
	for (int i = 0; i <=a-b; i++) {
		MAX = max(MAX, f[a] - ((f[i + b] - f[i]) - max((ll)0, d[i + b] - d[i])));
	}
	cout << MAX << endl;
}