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

int main(){
    int n, k;
    cin >> n >> k;
    ll a[n+1];
    for(int i = 0; i < n; i++) cin >> a[i];
    ll sum1[100005] = {};
    ll sum2[100005] = {};
    for(int i = 0; i < n; i++){
        sum1[i + 1] = sum1[i] + max(0LL, a[i]);
        sum2[i + 1] = sum2[i] + a[i];
    }
    ll ans = -1e18;
    for(int i = 0; i + k <= n; i++){
        ll tmp = sum1[i] + sum1[n] - sum1[i+k];
        tmp += max(0LL, sum2[i+k] - sum2[i]);
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}