#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <vector>

int main() {
  size_t N, K;
  scanf("%zu %zu", &N, &K);

  std::vector<intmax_t> a(N);
  for (size_t i=0; i<N; ++i)
    scanf("%jd", &a[i]);

  std::vector<intmax_t> aa(N+1), as(N+1);
  for (size_t i=1; i<=N; ++i) {
    aa[i] = aa[i-1] + a[i-1];
    as[i] = as[i-1] + std::max<intmax_t>(0, a[i-1]);
  }

  intmax_t res=0;
  for (size_t i=0; i+K<N+1; ++i) {
    res = std::max(res,
                   as[i]+std::max<intmax_t>(0, aa[i+K]-aa[i])+(as[N]-as[i+K]));
  }

  printf("%jd\n", res);
}
