#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  long long N, K;
  cin >> N >> K;
  vector<long long> A(N);
  for (auto &a : A) cin >> a;
  long long allSum = 0;
  for (auto &a : A) allSum += max(a, 0LL);
  long long res = 0;
  if (K == 1) {
    cout << allSum << endl;
  }
  {
    long long sum = 0;
    for (long long i = 0; i < K; ++i) {
      if (A[i] < 0) sum += A[i];
    }
    long long mi = -1e9 - 1;
    for (long long i = K; i < N; ++i) {
      if (A[i - K] < 0) sum -= A[i - K];
      if (A[i] < 0) sum += A[i];
      res = max(res, allSum + sum);
    }
  }
  {
    long long sum = 0;
    for (long long i = 0; i < K; ++i) {
      if (A[i] > 0) sum += A[i];
    }
    long long mi = -1e9 - 1;
    for (long long i = K; i < N; ++i) {
      if (A[i - K] > 0) sum -= A[i - K];
      if (A[i] > 0) sum += A[i];
      res = max(res, allSum - sum);
    }
  }
  cout << res << endl;
}
