#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T& x) {
  int f = 1;
  x = 0;
  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();
  }
  x *= f;
}
const int N = 100000 + 5;
int n, k;
long long a[N], s[N], f[N], g[N];
int main() {
  read(n), read(k);
  for (int i = 1; i <= n; i++) read(a[i]);
  for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i];
  for (int i = 1; i <= n; i++) f[i] = (a[i] > 0 ? f[i - 1] + a[i] : f[i - 1]);
  for (int i = n; i; i--) g[i] = (a[i] > 0 ? g[i + 1] + a[i] : g[i]);
  long long ans = -(1LL << 60);
  for (int i = 1; i + k - 1 <= n; i++) {
    long long tmp = s[i + k - 1] - s[i - 1];
    ans = max(ans, f[i - 1] + max(tmp, 0LL) + g[i + k]);
  }
  printf("%lld\n", ans);
  return 0;
}
