#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<long long int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<long long int> s(N);
  s[0] = A[0];
  for (int i = 1; i < N; i++) s[i] = s[i - 1] + A[i];
  vector<long long int> ps(N);
  if (A[0] >= 0)
    ps[0] = A[0];
  else
    ps[0] = 0;
  for (int i = 1; i < N; i++) {
    if (A[i] >= 0)
      ps[i] = ps[i - 1] + A[i];
    else
      ps[i] = ps[i - 1];
  }
  long long int gsum = 0;
  for (int i = 0; i < N - K + 1; i++) {
    long long int psum, sum;
    if (i >= 1)
      psum = s[i + K - 1] - s[i - 1];
    else
      psum = s[i + K - 1];
    if (psum >= 0)
      sum = psum + ps[N - 1] - (ps[i + K - 1] - ps[i - 1]);
    else
      sum = ps[N - 1] - (ps[i + K - 1] - ps[i - 1]);
    if (sum >= gsum) gsum = sum;
  }
  cout << gsum << endl;
  return 0;
}
