#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, k, a[100005], p[100005], q[100005], b[100005];
int mm(int x) { return x > 0 ? x : 0; }
int main() {
  n = read(), k = read();
  for (int i = 1; i <= n; i++) a[i] = read(), b[i] = b[i - 1] + a[i];
  for (int i = 1; i <= n; i++) p[i] = p[i - 1] + (a[i] > 0 ? a[i] : 0);
  for (int i = n; i >= 1; i--) q[i] = q[i + 1] + (a[i] > 0 ? a[i] : 0);
  int ans = -0x7fffffff;
  for (int i = 1; i + k - 1 <= n; i++)
    ans = max(ans, p[i - 1] + q[i + k] + mm(b[i + k - 1] - b[i - 1]));
  printf("%d", ans);
}
