#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 + 1];
  int idealScore[N + 1];
  blackImos[0] = 0;
  idealScore[0] = 0;
  for (int i = (0); i < (N + 1); ++i) {
    blackImos[i + 1] = board[i] + blackImos[i];
    idealScore[i + 1] = max(0, board[i]) + idealScore[i];
  }
  long long ans = 0;
  for (int i = (0); i < (N - K + 1); ++i) {
    long long sum = idealScore[N];
    long long blackScore = blackImos[i + K] - blackImos[i];
    long long score = sum - (idealScore[i + K] - idealScore[i]);
    ans = max(ans, score + 0);
    ans = max(ans, score + blackScore);
  }
  cout << ans << endl;
  return 0;
}
