#include <bits/stdc++.h>
using namespace std;
template <typename X>
bool exist(vector<X> vec, X item) {
  return find(vec.begin(), vec.end(), item) != vec.end();
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
vector<long long> a;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, K;
  cin >> N >> K;
  long long allsum = 0;
  for (long long i = (long long)0; i < (long long)N; i++) {
    long long inp;
    cin >> inp;
    a.push_back(inp);
    if (inp > 0) allsum += inp;
  }
  long long partsum = 0;
  long long partpos = 0;
  for (long long i = (long long)0; i < (long long)K; i++) {
    partsum += a[i];
    if (a[i] > 0) partpos += a[i];
  }
  long long ans = 0;
  for (long long i = (long long)0; i < (long long)N; i++) {
    if (i <= (K - 1)) continue;
    long long ansbefore = allsum - partpos;
    if (partsum > 0) ansbefore += partsum;
    if (a[i - K] > 0) partpos -= a[i - K];
    partsum -= a[i - K];
    if (a[i] > 0) partpos += a[i];
    partsum += a[i];
    long long ansafter = allsum - partpos;
    if (partsum > 0) ansafter += partsum;
    ans = max(ans, ansbefore);
    ans = max(ans, ansafter);
  }
  cout << ans << endl;
  return 0;
}
