#include <iostream>
#include <algorithm>

using namespace std;

#define ll long long
#define MAXN 100000

ll sum[MAXN + 1], sa[MAXN + 1];

int main() {
    int n, k;
    cin >> n >> k;

    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;

        sum[i] = x + sum[i - 1];
        sa[i] = sa[i - 1];
        if (x > 0)
            sa[i] += x;
    }

    ll ans = 0;
    for (int i = 1; i <= n - k + 1; i++)
        ans = max(ans, sa[i - 1] + sa[n] - sa[i + k - 1] + max(0LL, sum[i + k - 1] - sum[i - 1]));

    cout << ans;

    return 0;
}
