#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000;
long long b[maxn + 10];
long long w[maxn + 10];
int main() {
  int n, k;
  long long x;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    w[i] += w[i - 1];
    b[i] += b[i - 1];
    scanf("%lld", &x);
    if (x > 0) w[i] += x;
    if (x < 0) b[i] += x;
  }
  long long maxb = b[k] - b[0];
  long long minw = w[k] - w[0];
  for (int i = 1; i <= n - k; ++i) {
    int tempb = b[k + i] - b[i];
    int tempw = w[k + i] - w[i];
    if (tempb > maxb) maxb = tempb;
    if (tempw < minw) minw = tempw;
  }
  if (w[n] - minw > w[n] + maxb)
    printf("%lld", w[n] - minw);
  else
    printf("%lld", w[n] + maxb);
  return 0;
}
