#include <bits/stdc++.h>
long long int sum[100500], num[100500], ans = 0, ma = 0, ans2 = 0;
int n, k, start = 0, stop = 0;
int main() {
  scanf("%d %d", &n, &k);
  sum[0] = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &num[i]);
    sum[i] = num[i] + sum[i - 1];
  }
  for (int i = n; i >= k; i--) {
    if (sum[i] - sum[i - k] > ma) {
      ma = sum[i] - sum[i - k];
      start = i - k + 1;
      stop = i;
    }
  }
  for (int i = 1; i < start; i++)
    if (num[i] > 0) ans += num[i];
  for (int i = stop + 1; i <= n; i++)
    if (num[i] > 0) ans += num[i];
  ans += ma;
  ma = 0;
  for (int i = n; i >= k; i--) {
    if (sum[i] - sum[i - k] < ma) {
      ma = sum[i] - sum[i - k];
      start = i - k + 1;
      stop = i;
    }
  }
  for (int i = 1; i < start; i++)
    if (num[i] > 0) ans2 += num[i];
  for (int i = stop + 1; i <= n; i++)
    if (num[i] > 0) ans2 += num[i];
  if (ans > ans2)
    printf("%lld", ans);
  else
    printf("%lld", ans2);
}
