#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N, K;
	cin >> N >> K;
	ll a[N + 2], b[N + 2];
	a[0] = a[N + 1] = b[0] = b[N + 1] = 0;
	rep(i, 1, N + 1) {
		cin >> a[i];
		b[i] = max(a[i], 0);
	}

	rep(i, 1, N) {
		a[i + 1] += a[i];
		b[i + 1] += b[i];
	}

	ll rsl = 0;
	for(int i = 0; i + K <= N; i++) {
		ll tmp = a[i] + b[i + K] - b[i] + a[N] - a[i + K];

		rsl = max(rsl, tmp);
	}


	cout << rsl << endl;


	

}
