#include <bits/stdc++.h>
#define fin(i, n) for (int i = 0; i < n; i++)
#define fin2(i, a, b) for (int i = a; i < b; i++)
#define ll long long

using namespace std;

int main() {
	ll n, k;
	scanf("%lld%lld", &n, &k);
	vector<ll> t(n);
	fin(i, n) scanf("%lld", &t[i]);
	ll sum = 0;
	fin(i, k) sum += t[i];
	ll summ = sum;
	ll ind = 0;
	fin2(i, k, n) {
		sum += t[i] - t[i - k];
		if (sum > summ) {
			summ = sum;
			ind = i - k + 1;
		}
	}
	ll sump = sum;
	fin(i, n) if (i < ind || i >= ind + k) sump += max(0, t[i]);
	cout << max(0, sump);
}