#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)

int main(){
    long long n, k;
    cin >> n >> k;
    vector<long long> A(n);
    REP(i, n) cin >> A[i];

    vector<long long> X(n + 1, 0), Y(n + 1, 0);
    REP(i, n){
        X[i + 1] = A[i] + X[i];
        Y[i + 1] = max(0ll, A[i]) + Y[i];
    }

    long long ma = -1e18;
    REP(i, n - k + 1){
        ma = max(ma, max(0ll, X[i + k] - X[i]) + Y[n] - (Y[i + k] - Y[i]));
    }
    cout << ma << endl;

    return 0;
}