#include <bits/stdc++.h>
long long int sum[100500], num[100500], ans = 0, ma = 0, plu[100500];
int n, k, start = 0, stop = 0;
int main() {
  scanf("%d %d", &n, &k);
  sum[0] = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &num[i]);
    sum[i] = num[i] + sum[i - 1];
    if (num[i] > 0) plu[i] = num[i];
  }
  for (int i = 1; i <= n; i++) plu[i] += plu[i - 1];
  for (int i = n; i >= k; i--) {
    if (sum[i] - sum[i - k] <= 0) {
      if (plu[i - k] + plu[n] - plu[i] > ans)
        ans = plu[i - k + 1] + plu[n] - plu[i];
    } else if (plu[i - k] + plu[n] - plu[i] + sum[i] - sum[i - k] > ans)
      ans = plu[i - k] + plu[n] - plu[i] + sum[i] - sum[i - k];
  }
  printf("%lld", ans);
}
