#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
long long suma[maxn], sumz[maxn];
long long num[maxn];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &num[i]);
    suma[i] = suma[i - 1] + num[i];
    if (num[i] >= 0) {
      sumz[i] = sumz[i - 1] + num[i];
    } else {
      sumz[i] = sumz[i - 1];
    }
  }
  long long ans = -1;
  for (int i = 1; i <= n - k - 1; i++) {
    long long sum = 0;
    long long temp = suma[i + k - 1] - suma[i] + num[i];
    sum += temp >= 0 ? temp : 0;
    sum += sumz[i - 1] + sumz[n] - sumz[i + k - 1];
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
