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

int N, K, a[100005], sump[100005], sum[100005], ans;

signed main()
{
    cin >> N >> K;
    for(int i = 1; i <= N; i++){
        cin >> a[i];
        sump[i] = sump[i - 1] + a[i] * (int)(a[i] > 0);
        sum[i] = sum[i - 1] + a[i];
    }
    for(int i = 1; i <= N - K + 1; i++){
        ans = max(ans, sump[i - 1] + sump[N] - sump[i + K - 1] + (sum[i + K - 1] - sum[i - 1]) * (int)(sum[i + K - 1] - sum[i - 1] > 0));
    }
    cout << ans << endl;

    return 0;
}
