#include <bits/stdc++.h>
signed long long a[100000];
int n, m;
int i, j, k;
void deb() { return; }
unsigned long long abs(signed long long n) {
  return (unsigned long long)((n > 0) ? n : -n);
}
void solve() {
  signed long long result = 0;
  signed long long total = 0;
  signed long long rangetot = 0;
  for (i = 0; i < n; i++) {
    if (a[i] >= 0) total += a[i];
  }
  for (i = 0; i < k; i++) {
    if (a[i] >= 0) total -= a[i];
    rangetot += a[i];
  }
  puts("deb line B");
  while (i <= n) {
    unsigned long long candid;
    candid = total;
    if (rangetot > 0) candid += rangetot;
    if (result < candid) result = candid;
    if (a[i - k] >= 0) total += a[i - k];
    rangetot -= a[i - k];
    if (a[i] >= 0) total -= a[i];
    rangetot += a[i];
    i++;
  }
  printf("%lld\n", result);
  return;
}
int main(void) {
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) scanf("%lld", &a[i]);
  puts("deb line A");
  solve();
  return 0;
}
