#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[200000];
int sum[200000];
int sumz[200000];
int mx = -(int)1e9;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum[i] = sum[i - 1] + a[i];
    if (a[i] > 0) {
      sumz[i] = sumz[i - 1] + a[i];
    } else {
      sumz[i] = sumz[i - 1];
    }
  }
  if (n <= k) {
    printf("%d", max(sum[n], 0));
    return 0;
  }
  for (int i = 1; i <= n - k + 1; i++) {
    int t =
        sumz[i - 1] + sumz[n] - sumz[i + k - 1] + sum[i + k - 1] - sum[i - 1];
    mx = max(mx, t);
  }
  for (int i = 1; i <= n - k + 1; i++) {
    int t = sumz[i - 1] + sumz[n] - sumz[i + k - 1];
    mx = max(mx, t);
  }
  printf("%d", mx);
  return 0;
}
