#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  vector<int> inputs;
  cin >> N >> K;
  int i;
  int a;
  int inputSum = 0;
  for (i = 0; i < N; i++) {
    cin >> a;
    inputSum += (a > 0) ? a : 0;
    inputs.push_back(a);
  }
  int whiteloss = 0;
  int blackloss = 0;
  for (i = 0; i < K; i++) {
    whiteloss += inputs[i] > 0 ? inputs[i] : 0;
    blackloss += inputs[i] < 0 ? -inputs[i] : 0;
  }
  int minloss = whiteloss > blackloss ? blackloss : whiteloss;
  for (i = 0; i + K < N; i++) {
    whiteloss -= inputs[i] > 0 ? inputs[i] : 0;
    blackloss -= (inputs[i] < 0) ? -inputs[i] : 0;
    whiteloss += inputs[i + K] > 0 ? inputs[i + K] : 0;
    blackloss += inputs[i + K] < 0 ? -inputs[i + K] : 0;
    if (minloss > whiteloss) minloss = whiteloss;
    if (minloss > blackloss) minloss = blackloss;
  }
  if (minloss < 0) return 1;
  cout << inputSum - minloss << endl;
  return 0;
}
