#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  long long sum = 0;
  long long ans = 0;
  int ara[n];
  for (int i = 0; i < n; i++) scanf("%d", &ara[i]), ans += ara[i];
  for (int i = 0; i < k; i++) sum += ara[i];
  long long nwRest = 0;
  for (int i = k; i < n; i++)
    if (ara[i] > 0) nwRest += ara[i];
  for (int i = k; i < n; i++) {
    sum -= ara[i - k] - ara[i];
    if (ara[i] > 0) nwRest -= ara[i];
    if (ara[i - k] > 0) nwRest += ara[i - k];
    ans = max(ans, nwRest);
    ans = max(ans, nwRest + sum);
  }
  cout << ans << endl;
  return 0;
}
