#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N, K;
    std::cin >> N >> K;

    std::vector<int64_t> S, P;
    int64_t sum = 0;
    int64_t sump = 0;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        sum += t;
        if (t > 0) {
            sump += t;
        }
        S.push_back(sum);
        P.push_back(sump);
    }

    int64_t m = 0;

    for (int64_t i = 0; i <= N-K; ++i) {
        int64_t pre = (i > 0) ? P[i] : 0;
        auto b = S[i+K-1] - S[i];
        int64_t post = (i < N-K) ? P[N-1] - P[i+K] : 0;

        m = std::max(m, pre+b+post);
    }
    std::cout << m << std::endl;

    return 0;
}
