#include <bits/stdc++.h>
int v, a[100001], b[100001];
long long max(long long p, long long q) {
  if (p > q) return p;
  return q;
}
using namespace std;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i < n + 1; i++) {
    scanf("%lld", &v);
    a[i] = v + a[i - 1];
    b[i] = b[i - 1];
    if (v > 0) b[i] += v;
  }
  long long ans = -1;
  for (int i = 1; i <= n - k + 1; i++) {
    ans = max(ans, max(a[i + k - 1] - a[i - 1], 0) + b[i - 1] +
                       (b[n] - b[i + k - 1]));
  }
  printf("%lld", ans);
}
