#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
long long solve_(long long N, long long K, std::vector<long long> &a,
                 bool lastBlack) {
  long long acc = 0;
  for (int(n) = 0; (n) < (K); ++(n)) {
    acc += a[n];
  }
  long long maxAcc = acc;
  long long i = K - 1;
  for (long long n = K; n < N; n++) {
    acc = acc - a[n - K] + a[n];
    if ((lastBlack && maxAcc < acc) || (!lastBlack && maxAcc > acc)) {
      maxAcc = acc;
      i = n;
    }
  }
  long long ans = 0;
  if (lastBlack) {
    ans = maxAcc;
  }
  for (int(n) = 0; (n) < (N); ++(n)) {
    if (i - K + 1 <= n && n <= i) {
      continue;
    }
    if (a[n] > 0) {
      ans += a[n];
    }
  }
  return ans;
}
void solve(long long N, long long K, std::vector<long long> a) {
  long long ans1 = solve_(N, K, a, true);
  long long ans2 = solve_(N, K, a, false);
  cout << max(ans1, ans2) << endl;
}
int main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, K, std::move(a));
  return 0;
}
