#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll dat[100000];
ll rui[100001];
ll r2[100001];
int main()
{
	int num, kai;
	scanf("%d%d", &num, &kai);
	for (int i = 0; i < num; i++)scanf("%lld", &dat[i]);
	for (int i = 0; i < num; i++)
	{
		rui[i + 1] = rui[i] + dat[i];
		if (dat[i] >= 0)r2[i + 1] = r2[i] + dat[i];
		else r2[i + 1] = r2[i];
	}
	ll maxi = 0;
	for (int i = 0; i < num - kai + 1; i++)
	{
		maxi = max(maxi, (r2[i] - r2[0]) + (max(0LL,rui[i + kai] - rui[i])) + (r2[num] - r2[i + kai]));
	}
	printf("%lld\n", maxi);
}