#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
bool vis[100005];
int n,k,a[100005];
long long ans;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n-k;++i){
		scanf("%d",&a[i]);
		if(a[i]>0) ans+=a[i],vis[i]=1;
	}
	for(int i=n-k+1;i<=n;++i) scanf("%d",&a[i]);
	for(int i=n;i>k;--i){
		if(a[i]>0&&!vis[i]){
			int sum=ans+a[i],sum2=sum;
			for(int j=1;j<k;++j)
				sum-=a[i-j]*vis[i-j],
				sum2+=a[i-j]*(vis[i-j]^1);
			if(sum>ans&&sum>sum2){
				for(int p=1;p<=n;++p) vis[i-p]=0;
				ans=sum;vis[i]=1;
			}
			else if(sum2>ans&&sum2>sum){
				for(int p=1;p<=n;++p) vis[i-p]=1;
				ans=sum2;vis[i]=1;
			}
		}
	}
	printf("%d",ans);
}