#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int32 N;
	int32 K;
	vector<int64> a, sum, l, r;
	cin >> N >> K;
	a.resize(N);
	sum.resize(N+1, 0);
	l.resize(N+1, 0);
	r.resize(N+1, 0);
	REP(i, N) cin >> a[i];
	REP(i, N){
		sum[i+1] += sum[i]+a[i];
		l[i+1] += l[i]+max(0LL, a[i]);
	}
	for(int32 i = N-1;i >= 0;i--){
		r[i] += r[i+1]+max(0LL, a[i]);
	}
	int64 res = -INF_LL;
	REP(i, N-K+1){
		chmax(res, l[i]+max(0LL, sum[i+K]-sum[i])+r[i+K]);
	}
	cout << res << endl;
}