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

signed main(){

    int n, k; cin >> n >> k;
    vector<int> a(n + 1, 0LL);
    vector<int> b(n + 1, 0LL);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        b[i] = max(0LL, a[i]);
        a[i] += a[i - 1];
        b[i] += b[i - 1];
    }

    int ans = 0;
    for(int l = 1; l <= n; l++){
        int r = l + k - 1;
        if(r > n) continue;
        ans = max(ans, b[l - 1] + b[n] - b[r] + max(0LL, a[r] - a[l - 1]));
    }

    cout << ans << endl;

    return 0;
}