#include<bits/stdc++.h>
using namespace std;
int main() {
    long long int N,K;
    long long int A[100500];
    long long int M[100500];
    long long int m[100500];
    long long int ans = -1;
	cin >> N >> K;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		m[i] = m[i - 1];
		M[i] = M[i - 1];
		if (A[i] > 0)M[i] += A[i];
		else m[i] += A[i];
	}
	for (int i = K; i <= N; i++) {
		ans = max(ans, M[N] + m[i] - m[i - K]);
	}
	for (int i = K; i <= N; i++) {
		ans = max(ans, M[N] - M[i] + M[i - K]);
	}
	cout << ans << endl;
	return 0;
}