#include <cstdio>
#include <algorithm>
int N, K;
long long a[100001], s[100001], f[100001], O;
int main()
{
	scanf("%d%d", &N, &K);
	for (int i = 1; i <= N; i++)
		scanf("%lld", a + i);
	for (int i = 1; i <= N; i++)
	{
		s[i] = s[i - 1] + a[i];
		f[i] = f[i - 1] + std::max(a[i], 0LL);
	}
	for (int i = K; i <= N; i++)
		O = std::max(O, std::max(s[i] - s[i - K], 0LL) + f[i - K] + f[N] - f[i]);
	printf("%lld\n", O);
	return 0;
}
