#include <bits/stdc++.h>
using namespace std;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  long long int a[100010];
  for (int i = 0; i < N; i++) cin >> a[i];
  long long int sum0 = 0, sum1 = 0;
  for (int i = 0; i < N; i++) sum1 += max(0LL, a[i]);
  for (int i = 0; i < K; i++) {
    sum1 -= max(0LL, a[i]);
    sum0 += a[i];
  }
  long long int ans = sum1 + max(0LL, sum0);
  for (int i = 0; i < N - K; i++) {
    sum1 = sum1 + max(0LL, a[i]) - max(0LL, a[K + i]);
    sum0 = sum0 - a[i] + a[K + i];
    ans = sum1 + max(0LL, sum0);
  }
  cout << ans << endl;
  return 0;
}
