#include <stdio.h>
#include <iostream>
#define int long long

using namespace std;

const int N=123456;

int a[N];
int b[N];

signed main() {
    int n,k;
    int gh;
    cin>>n>>k;
    for(int i=1;i<=n;i++) {
        cin>>gh;
        a[i]=gh;
        a[i]+=a[i-1];
        if(gh>=0) b[i]=b[i-1]+gh;
        else b[i]=b[i-1];
    }
    int ans=0;
    for(int i=1;i<=n-k+1;i++) {
        int foo=a[k+i-1]-a[i-1];
        foo=max(foo,0ll);
        ans=max(ans,foo+b[i-1]+b[n]-b[k+i-1]);
    }
    cout<<ans<<endl;
    return 0;
}
