#include <bits/stdc++.h>
using namespace std;
template <typename qwq>
inline void read(qwq& x) {
  x = 0;
  register int f = 1;
  register char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  x *= f;
}
template <typename qaq>
inline void print(qaq x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
long long n, k, ans;
long long a[233333], s[233333], pre[233333], Next[233333];
int main() {
  read(n), read(k);
  for (register int i = 1; i <= n; ++i) {
    read(a[i]);
    s[i] = s[i - 1] + a[i];
    pre[i] = pre[i - 1] + (a[i] > 0 ? a[i] : 0);
  }
  for (register int i = n; i >= 1; --i)
    Next[i] = Next[i + 1] + (a[i] > 0 ? a[i] : 0);
  for (register int i = 0; i <= n - k; ++i) {
    register int lr = pre[i] + Next[i + k + 1], mid = s[i + k] - s[i];
    ans = (ans > lr + (mid > 0 ? mid : 0) ? ans : lr + (mid > 0 ? mid : 0));
  }
  print(ans);
}
