#include <bits/stdc++.h>
signed main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  long long n, k;
  std::cin >> n >> k;
  std::vector<long long> pts(n), positive(n);
  for (long long i = 0; i < n; i++) {
    std::cin >> pts[i];
    positive[i] = std::max(0ll, pts[i]);
  }
  std::vector<long long> accum = {0}, pos_accum = {0};
  std::partial_sum(std::begin(pts), std::end(pts), std::back_inserter(accum));
  std::partial_sum(std::begin(positive), std::end(positive),
                   std::back_inserter(pos_accum));
  long long result = std::numeric_limits<long long>::min() / 2;
  for (long long i = 0; i < n - k + 1; i++) {
    long long range_sum = accum[i + k] - accum[i],
              other_sum = pos_accum[n] - pos_accum[i + k] + pos_accum[i];
    result = std::max({result, range_sum + other_sum, other_sum});
  }
  std::cout << result << std::endl;
}
