#include <bits/stdc++.h>
using namespace std;
long long a[100005], s[100005], ans;
int n, k;
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    s[i] = a[i] + s[i - 1];
  }
  long long maxx = 0;
  int l, r;
  for (int i = k; i <= n; i++) {
    if (maxx < s[i] - s[i - k]) {
      maxx = s[i] - s[i - k];
      l = i - k + 1;
      r = i;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i < l || i > r)
      if (a[i] > 0) ans += a[i];
  }
  ans += maxx;
  printf("%lld", ans);
  return 0;
}
