#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int64_t> as(n);
  for (auto &a : as) cin >> a;
  vector<int64_t> sum(n + 1);
  for (int i = 1; i <= n; i++) {
    sum[i] = (as[i - 1] > 0 ? as[i - 1] : 0) + sum[i - 1];
  }
  int64_t best = 0, cur = 0;
  for (int i = 0; i < n; i++) {
    cur += as[i];
    if (i - k + 1 < 0) continue;
    cur -= as[i - k + 1];
    int l = i - k + 1;
    int r = i + 1;
    int64_t tmp1 = (sum[l] - sum[0]) + cur + (sum[n] - sum[r]);
    int64_t tmp2 = (sum[l] - sum[0]) + 0 + (sum[n] - sum[r]);
    best = max(best, tmp1);
    best = max(best, tmp2);
  }
  cout << best << endl;
  return 0;
}
