#include <bits/stdc++.h>
using namespace std;
bool prime(long long x) {
  for (long long i = 2; i * i <= x; i++) {
    if (x % i == 0) return false;
  }
  return x > 1;
}
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long lcm(long long x, long long y) { return x * y / gcd(x, y); }
long long kai(long long x) {
  if (x == 0) return 1;
  return kai(x - 1) * x % (long long)(1e9 + 7);
}
long long mod_pow(long long x, long long y, long long mod_) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) {
      res = res * x % mod_;
    }
    x = x * x % mod_;
    y >>= 1;
  }
  return res;
}
long long comb(long long x, long long y) {
  return kai(x) *
         mod_pow(kai(x - y), (long long)(1e9 + 7) - 2, (long long)(1e9 + 7)) %
         (long long)(1e9 + 7) *
         mod_pow(kai(y), (long long)(1e9 + 7) - 2, (long long)(1e9 + 7)) %
         (long long)(1e9 + 7);
}
long long n, k;
long long a[114514];
long long sum[114514], psum[114514];
signed main() {
  cin >> n >> k;
  for (long long i = 0; i < n; i++) cin >> a[i];
  sum[0] = a[0], psum[0] = max(0LL, a[0]);
  for (long long i = 1; i < n; i++) {
    sum[i] += sum[i - 1];
    psum[i] += psum[i - 1];
    sum[i] += a[i];
    psum[i] += max(0LL, a[i]);
  }
  long long ans = max(0LL, sum[k]) + psum[n - 1] - psum[k];
  for (long long i = 1; i < n - k + 1; i++) {
    ans = max(ans, max(0LL, sum[i + k - 1] - sum[i - 1]) + psum[i - 1] +
                       psum[n - 1] - psum[i + k - 1]);
  }
  cout << ans << endl;
}
