#include <bits/stdc++.h>
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, k;
  std::cin >> n >> k;
  std::vector<int> pts(n);
  for (auto& i : pts) std::cin >> i;
  int current_sum = 0;
  for (int i = 0; i < k; i++) current_sum += pts[i];
  int max_sum = current_sum, max_l = 0, min_sum = current_sum, min_l = 0;
  for (int i = 1; i < n - k + 1; i++) {
    current_sum += pts[i + k - 1];
    current_sum -= pts[i - 1];
    if (current_sum > max_sum) {
      max_sum = current_sum;
      max_l = i;
    }
    if (current_sum < min_sum) {
      min_sum = current_sum;
      min_l = i;
    }
  }
  int paint_l, paint_sum;
  std::tie(paint_sum, paint_l) =
      std::max<std::pair<int, int>>({max_sum, max_l}, {0, min_l});
  int result = paint_sum;
  for (int i = 0; i < n; i++) {
    if (i >= paint_l && i < paint_l + k) continue;
    if (pts[i] > 0) result += pts[i];
  }
  std::cout << result << std::endl;
}
