#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n, k, ans=-1e18;
int a[N], pref[N], pos[N];

int32_t main()
{
	IOS;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		pref[i] = pref[i-1] + a[i];
		pos[i] = pos[i-1] + ((a[i]>0)?a[i]:0);
	}
	for(int i=1;i+k-1<=n;i++)
	{
		int others=pos[i-1] + pos[n] - pos[i+k-1];
		int range=pref[i+k-1] - pref[i-1];
		if(range<0)
			range=0;
		ans=max(ans, others + range);
	}	
	cout<<ans;
	return 0;
}
