#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  int K;
  cin >> N >> K;
  int board[N];
  for (int i = (0); i < (N); ++i) {
    cin >> board[i];
  }
  int blackImos[N];
  int fixPositive[N];
  int idealScore[N];
  blackImos[0] = board[0];
  fixPositive[0] = max(blackImos[0], 0);
  idealScore[0] = fixPositive[0];
  for (int i = (1); i < (N); ++i) {
    blackImos[i] = board[i] + blackImos[i - 1];
    fixPositive[i] = max(board[i], 0);
    idealScore[i] = fixPositive[i] + idealScore[i - 1];
  }
  int sum = 0;
  int begin = 0;
  int end = K - 1;
  int negScore = 0;
  for (int i = (0); i < (N - K + 1); ++i) {
    int blackScore = blackImos[i + K - 1] - blackImos[i];
    if (sum < blackScore) {
      begin = i;
      end = i + K - 1;
      sum = blackScore;
    }
    if (sum == 0 && (negScore > blackScore)) {
      begin = i;
      end = i + K - 1;
      negScore = min(blackScore, negScore);
    }
  }
  int ans = 0;
  if (sum > 0) {
    ans = sum;
  } else {
  }
  if (begin == 0) {
    ans += idealScore[N - 1] - (idealScore[end] - idealScore[begin]);
  } else {
    ans += idealScore[N - 1] - (idealScore[end] - idealScore[begin - 1]);
  }
  cout << ans << endl;
  return 0;
}
