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

const int MAX_N = 100000;
const int INF = LLONG_MAX/10;

int N, K, A[MAX_N + 1];

signed main()
{
	int ans = -INF, score = 0, latte = 0;
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		if (A[i] > 0) score += A[i];
	}
	int l = 0, r = 0;
	while (r < N)
	{
		while (r < l + K)
		{
			latte += A[r];
			if (A[r] > 0) score -= A[r];
			r++;
		}
		ans = max(ans, score + max(latte, 0ll));
		latte -= A[l];
		if (A[l] > 0) score += A[l];
		l++;
	}
	printf("%lld\n", ans);
	return 0;
}