#include <bits/stdc++.h>
int N, K;
int a[100010];
void solve() {
  int i;
  long long s1 = 0, s2 = 0, s3 = 0;
  for (i = 0; i < K; i++) s2 += a[i];
  for (i = K; i < N; i++) {
    if (a[i] > 0) s3 += a[i];
  }
  long long res;
  res = s1 + s3;
  if (s2 > 0) res += s2;
  for (i = 0; i < N - K; i++) {
    if (a[i] > 0) s1 += a[i];
    if (a[i + K] > 0) s3 -= a[i + K];
    s2 = s2 + a[i + K] - a[i];
    long long sum = s1 + s3;
    if (s2 > 0) sum += s2;
    if (sum > res) res = sum;
  }
  printf("%I64d\n", res);
}
int main() {
  int i;
  scanf("%d%d", &N, &K);
  for (i = 0; i < N; i++) scanf("%d", &a[i]);
  solve();
  return 0;
}
