#include <bits/stdc++.h>
using namespace std;
int n, k;
long long ans = 0, kk;
long long a[100010], sa[100010], sb[100010];
bool cmp(long long a, long long b) { return a < b; }
int main() {
  scanf("%d%d", &n, &k);
  int i, j;
  sa[0] = 0;
  sb[0] = 0;
  for (i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
    if (a[i] > 0)
      sa[i] = sa[i - 1] + a[i];
    else
      sa[i] = sa[i - 1];
    sb[i] = sb[i - 1] + a[i];
  }
  for (i = k; i <= n; ++i) {
    long long xx = sa[i] - sa[i - k], yy = sb[i - k] + sb[n] - sb[i];
    if (xx > 0) yy += xx;
    ans = max(ans, yy);
  }
  printf("%lld\n", ans);
}
