#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
void solve(long long N, long long K, std::vector<long long> a) {
  long long ans1 = 0;
  {
    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++) {
      long long nTmp = acc - a[n - K] + a[n];
      if (maxAcc < nTmp) {
        maxAcc = nTmp;
        i = n;
      }
      acc = nTmp;
    }
    ans1 = maxAcc;
    for (int(n) = 0; (n) < (N); ++(n)) {
      if (i - K + 1 <= n && n <= i) {
        continue;
      }
      if (a[n] > 0) {
        ans1 += a[n];
      }
    }
  }
  long long ans2 = 0;
  {
    long long acc = 0;
    for (int(n) = 0; (n) < (K); ++(n)) {
      acc += a[n];
    }
    long long minAcc = acc;
    long long i2 = K - 1;
    for (long long n = K; n < N; n++) {
      long long nTmp = acc - a[n - K] + a[n];
      if (minAcc > nTmp) {
        minAcc = nTmp;
        i2 = n;
      }
      acc = nTmp;
    }
    for (int(n) = 0; (n) < (N); ++(n)) {
      if (i2 - K + 1 <= n && n <= i2) {
        continue;
      }
      if (a[n] > 0) {
        ans2 += a[n];
      }
    }
  }
  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;
}
