#include <bits/stdc++.h>
int main() {
  long N, K;
  long a[100010];
  long sum[100010];
  long i, j;
  long tmp;
  long ans;
  long min_i, max_i;
  scanf("%ld", &N);
  scanf("%ld", &K);
  for (i = 0; i < N; i++) {
    scanf("%ld", &a[i]);
  }
  sum[0] = 0;
  for (i = 0; i < K; i++) {
    sum[0] += a[i];
  }
  min_i = max_i = 0;
  for (i = 1; i <= N - K; i++) {
    sum[i] = sum[i - 1] - a[i - 1] + a[K + i - 1];
    if (sum[min_i] > sum[i]) min_i = i;
    if (sum[max_i] < sum[i]) max_i = i;
  }
  tmp = 0;
  for (i = 0; i < N; i++) {
    if (min_i <= i && i < min_i + K) {
      ;
    } else {
      if (a[i] > 0) tmp += a[i];
    }
  }
  ans = tmp;
  tmp = 0;
  for (i = 0; i < N; i++) {
    if (max_i <= i && i < max_i + K) {
      tmp += a[i];
    } else {
      if (a[i] > 0) tmp += a[i];
    }
  }
  ans = (((ans) > (tmp)) ? (ans) : (tmp));
  printf("%ld\n", ans);
  return 0;
}
