#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;

    vector<int64_t> s(n + 1), t(n + 1);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        s[i + 1] = s[i] + a;
        t[i + 1] = t[i] + (a < 0 ? 0 : a);
    }

    int64_t r = 0;
    for (int i = 0; i <= n - k; i++) {
        int64_t u = max(s[i + k] - s[i], 0LL);
        u += t[i] - t[0];
        u += t[n] - t[i + k];
        r = max(r, u);
    }

    cout << r << endl;

    return 0;
}