#include <bits/stdc++.h>
using namespace std;
long long N, K;
long long a[123456], sum[123456];
signed main() {
  cin >> N >> K;
  for (long long i = 0, i_len = (N); i < i_len; ++i) cin >> a[i];
  for (long long i = 0, i_len = (N); i < i_len; ++i) sum[i + 1] = sum[i] + a[i];
  long long mi = (1LL << 60), mi_idx, ma = -(1LL << 60), ma_idx;
  for (long long i = 0, i_len = (N - K + 1); i < i_len; ++i) {
    if (mi > sum[i + K] - sum[i]) {
      mi = sum[i + K] - sum[i];
      mi_idx = i;
    }
    if (ma < sum[i + K] - sum[i]) {
      ma = sum[i + K] - sum[i];
      ma_idx = i;
    }
  }
  long long ans = -(1LL << 60);
  long long tmp = ma;
  for (long long i = 0; i < N; i++) {
    if (i < ma_idx || i > ma_idx + K - 1) tmp += max(0LL, a[i]);
  }
  ans = tmp;
  tmp = 0;
  for (long long i = 0; i < N; i++) {
    if (i < mi_idx || i > mi_idx + K - 1) tmp += max(0LL, a[i]);
  }
  ans = max(tmp, ans);
  cout << ans << endl;
  return 0;
}
