#include <bits/stdc++.h>
using namespace std;
long long a[100100], sum[100100];
long long qs[100100];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", a[i]);
    sum[i] = sum[i - 1];
    if (a[i] > 0) sum[i] += a[i];
    qs[i] = a[i];
    qs[i] += qs[i - 1];
  }
  long long ans = 0;
  for (int i = k; i <= n; i++) {
    ans = max(ans, sum[i - k] + qs[i] - qs[i - k]);
  }
  printf("%lld", ans);
}
