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

int main(){
    int N, K;  cin >> N >> K;
    vector<ll> a(N+1);
    for(int i=1; i<=N; i++)  cin >> a[i];
    
    vector<ll> S1(N+1,0), S2(N+1,0);
    for(int i=1; i<=N; i++){
        S1[i] = S1[i-1] + a[i];
        S2[i] = S2[i-1] + max(a[i], (ll)0);
    }

    ll ans = 0;
    for(int i=1; i<=N-K+1; i++){
        ll tmp = S1[i+K-1] - S1[i-1];
        if(tmp<0) tmp = 0;

        tmp += S2[i-1] + (S2[N] - S2[i+K-1]);
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}
