#include <bits/stdc++.h>
int main(int argc, char *argv[]) {
  int N, K;
  long long int *a;
  int ans = 0;
  scanf("%d%d", &N, &K);
  a = (long long int *)malloc(N * sizeof(long long int));
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
    if (a[i] > 0) ans += a[i];
  }
  long long int min, tmp = 0, tmp1 = 0;
  for (int i = 0; i < K; i++) {
    if (a[i] < 0)
      tmp -= a[i];
    else
      tmp1 += a[i];
  }
  if (tmp < tmp1)
    min = tmp;
  else
    min = tmp1;
  for (int i = K; i < N; i++) {
    int tmp2 = a[i - K];
    if (tmp2 < 0)
      tmp += tmp2;
    else
      tmp1 -= tmp2;
    if (a[i] < 0)
      tmp -= a[i];
    else
      tmp1 += a[i];
    if (tmp < min) min = tmp;
    if (tmp1 < min) min = tmp1;
  }
  printf("%lld\n", ans - min);
  return 0;
}
