#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 7;
int a[maxn], n, k, minsec, maxsec;
long long minh, maxh, ans, d[maxn], pl[maxn], mi[maxn], minv = 0x7f7f7f7f,
                                                        maxv = -0x7f7f7f7f;
bool flag;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    d[i] = d[i - 1] + a[i];
    pl[i] = pl[i - 1];
    mi[i] = mi[i - 1];
    if (a[i] > 0)
      pl[i] += a[i];
    else
      mi[i] += abs(a[i]);
  }
  for (int i = k; i <= n; ++i) {
    if (d[i] - d[i - k] > maxv) {
      maxv = d[i] - d[i - k];
      maxsec = i - k;
      maxh = mi[i] - mi[i - k];
    }
    if (d[i] - d[i - k] < minv) {
      minv = d[i] - d[i - k];
      minsec = i - k;
      minh = pl[i] - pl[i - k];
    }
  }
  if (minh < maxh) flag = true;
  for (int i = 1; i <= n; ++i) {
    if (flag) {
      if (i > minsec && i <= minsec + k)
        continue;
      else if (a[i] > 0)
        ans += a[i];
    } else if (i > maxsec && i <= maxsec + k)
      ans += a[i];
    else if (a[i] > 0)
      ans += a[i];
  }
  printf("%lld\n", ans);
  return 0;
}
