#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    long long n, k, ret = 0, tmp;
    std::cin >> n >> k;
    std::vector<long long> a(n), s(n), t(n);

    for (long long i = 0; i < n; i++) {
        std::cin >> a[i];
        s[i] = (i>0?s[i-1]:0) + a[i];
        t[i] = (i>0?t[i-1]:0) + std::max(0ll, a[i]);
    }
    
    for (long long i = 0; i < n - k + 1; i++) {
        ret = std::max(ret, std::max(s[i + k - 1] - s[i] + a[i], 0ll) + t[i] - std::max(0ll, a[i]) + t[n-1] - t[i+k-1]);
    }

    std::cout << ret << std::endl;

    return 0;
}