#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);
  for (auto& i : pts) std::cin >> i;
  std::vector<long long> accum = {0};
  std::partial_sum(std::begin(pts), std::end(pts), std::back_inserter(accum));
  long long max_sum = std::numeric_limits<long long>::min() / 2, max_l = 0,
            min_sum = std::numeric_limits<long long>::max() / 2, min_l = 0;
  for (long long i = 0; i < n - k + 1; i++) {
    long long current_sum = accum[i + k] - accum[i];
    if (current_sum > max_sum) {
      max_sum = current_sum;
      max_l = i;
    }
    if (current_sum < min_sum) {
      min_sum = current_sum;
      min_l = i;
    }
  }
  long long take_max = max_sum, take_min = 0;
  for (long long i = 0; i < n; i++) {
    if (pts[i] < 0) continue;
    if (i < max_l || i >= max_l + k) take_max += pts[i];
    if (i < min_l || i >= min_l + k) take_min += pts[i];
  }
  std::cout << std::max(take_max, take_min) << std::endl;
}
