#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  if (n < k) {
    printf("0");
    return 0;
  }
  long long int qsp[n + 1], qsn[n + 1], a;
  qsp[0] = qsn[0] = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &a);
    qsp[i] = qsp[i - 1];
    qsn[i] = qsn[i - 1];
    if (a > 0)
      qsp[i] += a;
    else
      qsn[i] += a;
  }
  long long int min = qsp[k], max = qsp[k] + qsn[k], maxidx = k;
  for (int i = k; i <= n; ++i) {
    if (qsp[i] - qsp[i - k] < min) min = qsp[i] - qsp[i - k];
    if (max < qsp[i] - qsp[i - k] + qsn[i] - qsn[i - k]) {
      max = qsp[i] - qsp[i - k] + qsn[i] - qsn[i - k];
      maxidx = i;
    }
  }
  if (max <= 0 || min == 0)
    printf("%lld", qsp[n] - min);
  else
    printf("%lld", qsp[n] + qsn[maxidx] - qsn[maxidx - k]);
}
