#include <bits/stdc++.h>
using namespace std;
long long dx[4] = {0, 1, 0, -1};
long long dy[4] = {1, 0, -1, 0};
signed main() {
  long long N, K, a[100005];
  cin >> N >> K;
  for (long long i = 0; i < N; i++) cin >> a[i];
  long long ma = -(1LL << 60);
  long long s = 0;
  for (long long i = 0; i < K; i++) {
    s += a[i];
  }
  ma = s;
  long long r = 0;
  for (long long i = 1; i + K - 1 < N; i++) {
    s += a[i + K - 1] - a[i - 1];
    if (s > ma) {
      ma = s;
      r = i;
    }
  }
  for (long long i = 0; i < N; i++) {
    if (a[i] > 0 && (i < r || i >= r + K)) ma += a[i];
  }
  long long mi = (1LL << 60);
  s = 0;
  for (long long i = 0; i < K; i++) {
    s += a[i];
  }
  mi = s;
  r = 0;
  for (long long i = 1; i + K - 1 < N; i++) {
    s += a[i + K - 1] - a[i - 1];
    if (s < mi) {
      mi = s;
      r = i;
    }
  }
  mi = max(0LL, mi);
  for (long long i = 0; i < N; i++) {
    if (a[i] > 0 && (i < r || i >= r + K)) mi += a[i];
  }
  cout << max(ma, mi) << endl;
  return 0;
}
