#include <bits/stdc++.h>
using namespace std;
int a[111111];
int kuro[111111];
int b[111111];
int main(void) {
  int N, K, x, i, j, k;
  int res, tmp;
  res = tmp = 0;
  scanf("%d %d", &N, &K);
  for (i = 1; i <= N; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 1; i <= K; i++) {
    kuro[1] += a[i];
  }
  for (i = 2; i <= N - K + 1; i++) {
    kuro[i] = kuro[i - 1] + a[i + K - 1] - a[i - 1];
  }
  b[1] = max(0, a[1]);
  for (i = 2; i <= N; i++) {
    b[i] = b[i - 1] + max(0, a[i]);
  }
  for (i = 1; i <= N - K + 1; i++) {
    tmp = kuro[i] + b[i - 1] + (b[N] - b[i + K - 1]);
    res = max(res, tmp);
  }
  for (i = 1; i <= N - K + 1; i++) {
    tmp = b[i - 1] + (b[N] - b[i + K - 1]);
    res = max(res, tmp);
  }
  printf("%d\n", res);
  return 0;
}
