#include <bits/stdc++.h>
using namespace std;
long long a[100010] = {}, sum = 0, realSum = 0, howPlus = 0;
long long plusK[100010] = {}, bubu[100010] = {};
int main() {
  long long n, k;
  cin >> n >> k;
  for (long long i = (0); i < ((n)); i++) {
    cin >> a[i];
    if (a[i] > 0) {
      howPlus++;
      sum += a[i];
    }
    realSum += a[i];
  }
  long long ans = -(1LL << 60);
  if (n == k) ans = max(0LL, realSum);
  for (int i = 0; i < n; i++) {
    if (i != 0) {
      plusK[i] += plusK[i - 1];
      bubu[i] += bubu[i - 1];
    }
    bubu[i] += a[i];
    if (a[i] > 0) plusK[i] += a[i];
    if (i - k >= 0 && a[i - k] > 0) plusK[i] -= a[i - k];
    if (i - k >= 0) bubu[i] -= a[i - k];
  }
  for (int i = n - 1; i >= k; i--) {
    if (sum == 0) {
      ans = max(ans, max(realSum - bubu[i], bubu[i]));
    } else {
      ans = max(ans, max(realSum - bubu[i], bubu[i]));
      ans = max(ans, max(sum - plusK[i], sum - plusK[i] + bubu[i]));
    }
  }
  cout << ans << endl;
  return 0;
}
