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