#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') {
      f = -1;
    }
    c = getchar();
  }
  while (c <= '9' && c >= '0') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
int n, k;
long long a[200000];
long long s[200000];
long long ss[200000];
long long sum;
long long maxx;
int main() {
  n = read();
  k = read();
  for (register int i = 1; i <= n; ++i) {
    a[i] = read();
    s[i] = s[i - 1] + a[i];
    if (a[i] > 0) {
      ss[i] = ss[i - 1] + a[i];
    } else {
      ss[i] = ss[i - 1];
    }
  }
  for (register int i = 1; i <= n - k + 1; ++i) {
    sum = 0;
    long long j = i + k - 1;
    if (s[j] - s[i - 1] >= 0) {
      sum += s[j] - s[i - 1];
    }
    sum += (ss[n] - ss[j]);
    sum += (ss[i - 1] - ss[0]);
    maxx = max(maxx, sum);
  }
  cout << maxx;
}
