#include <cstdio>
#include <iostream>
using namespace std;
int N, p[100003], K;
long long a[100003], b[100003], c[100003];
int main(){
    scanf("%d %d", &N, &K);
    long long ans = 0;
    for(int i = 1; i <= N; ++i) scanf("%d", &p[i]);
    for(int i = 1; i <= N; ++i) a[i] = a[i-1] + max(p[i], 0);
    for(int i = 1; i <= N; ++i) c[i] = c[i-1] + p[i];
    for(int i = N; i >= 1; --i) b[i] = b[i+1] + max(p[i], 0);
    for(int i = 1; i <= N - K + 1; ++i){
        ans = max(ans, max(0LL, c[i + K - 1] - c[i-1]) + a[i-1] + b[i + K]);
    }
    printf("%lld\n", ans);
}
