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

const int mnx = 1e6 + 9;
const int mod = 1e9 + 7;

ll n, k;
ll a[mnx];
ll suff[mnx];
ll pref[mnx];
ll b[mnx];

int main() {

cin >> n >> k;

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

ll res = -1;

for(int i = 0; i <= n - k; i++){
    res = max(res, pref[n] - (pref[i + k] - pref[i]) + max(0LL, b[i + k] - b[i]));
}

cout << res << '\n';

return 0;

}
