// https://atcoder.jp/contests/agc008/tasks/agc008_b
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<ll> v(n);
    ll sum = 0, pos = 0, now = 0, minv = 0, ncnt = 0;
    bool nflag = false;
    REP(i, n) {
        cin >> v[i];
        if (v[i] > 0)
            sum += v[i];
        if (v[i] <= 0) {
            ncnt++;
            if (ncnt >= k) {
                nflag = true;
            }
        } else {
            ncnt = 0;
        }
    }
    // マイナスがK個以上連続したら、プラスのみ加算
    if (nflag) {
        cout << sum << endl;
        return 0;
    }
    sum = 0;
    REP(i, k) now += v[i];
    minv = now;
    for (int i = k; i < n; i++) {
        now += v[i] - v[i - k];
        if (minv < now) {
            minv = now;
            pos = i - k + 1;
        }
    }
    for (int i = 0; i < pos; i++) {
        if (v[i] > 0)
            sum += v[i];
    }
    for (int i = pos + k; i < n; i++) {
        if (v[i] > 0)
            sum += v[i];
    }

    // 求めた最大値がマイナスなら、白にして加算しない
    cout << sum + max(0, minv) << endl;

    return 0;
}