#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<MAP>
#include<unordered_MAP>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define rep(i,n) FOR(i,0,n)

struct edge{int to,cost;};

void dump(ll *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n,k;
	cin >> n >> k;

	int a[n];
	ll rui[n+1]={};
	ll seirui[n+1]={};
	rep(i,n){
		cin >> a[i];
		rui[i+1]=rui[i]+a[i];
		if(a[i]>0) seirui[i+1]=seirui[i]+a[i];
		else	seirui[i+1]=seirui[i];
	}
	ll ans=0;
	for(int i=1;i<=n-k+1;i++){
//		cout << seirui[n]-seirui[i+k-1]+seirui[i-1]+max(0LL,rui[i+k-1]-rui[i-1]) << "\n";
		ans = max(ans,seirui[n]-seirui[i+k-1]+seirui[i-1]+max(0LL,rui[i+k-1]-rui[i-1]));
	}
	cout << ans << "\n";

	return 0;
}