#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod = 1e9 + 7;
int main() {
  ll N, K, a[100000];
  cin >> N >> K;
  for (int i(0); i < N; i++) cin >> a[i];
  ll b[100000] = {0};
  if (a[0] > 0) b[0] = a[0];
  for (int i(1); i < N; i++) {
    if (a[i] > 0) {
      b[i] = b[i - 1] + a[i];
    } else {
      b[i] = b[i - 1];
    }
  }
  ll c[100000] = {0};
  c[0] = a[0];
  for (int i(1); i < N; i++) {
    c[i] = c[i - 1] + a[i];
  }
  ll ans(0ll);
  for (int i(0); i <= N - K; i++) {
    ll sub(0);
    if (i == 0)
      sub = b[N - 1] - (b[i + K - 1]) + (c[i + K - 1]);
    else
      sub = b[N - 1] - (b[i + K - 1] - b[i - 1]) + (c[i + K - 1] - c[i - 1]);
    ans = max(sub, ans);
  }
  cout << ans << endl;
  return 0;
}
