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

typedef long long ll;
const int MAX_N = int(1e5) + 5;
#define REP(i, n) for (int i = 0; i < n; i++)

ll n, k, a[MAX_N], b[MAX_N]{} ,c[MAX_N]{};

int main() {
    cin >> n >> k;
    REP(i,n){
        cin >> a[i];
        b[i+1] += b[i] + a[i];
        if(a[i]>0)c[i+1] += a[i];
        c[i+1] += c[i];
    }
    ll ans = 0;
    REP(i,n-k+1){
        ans = max(ans,c[i]+c[n]-c[i+k]+max(0LL,b[i+k]-b[i]));
    }
    cout << ans << endl;
    return 0;
}
