#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int N, K, as[(100000)];
  scanf("%d %d", &N, &K);
  for (int i = 0; i < N; i++) {
    scanf("%d", &as[i]);
  }
  int accs[(100000) + 1], acc_poss[(100000) + 1];
  accs[0] = 0;
  acc_poss[0] = 0;
  for (int i = 0; i < N; i++) {
    accs[i + 1] = accs[i] + as[i];
    acc_poss[i + 1] = acc_poss[i] + max(as[i], 0);
  }
  long ans = 0;
  for (int k = 0; k < N - K + 1; k++) {
    const long sum_before = acc_poss[k] - acc_poss[0];
    const long sum_after = acc_poss[N] - acc_poss[k + K];
    const long sum_continuous = accs[k + K] - accs[k];
    ans = max(ans, sum_before + sum_after + max(sum_continuous, 0L));
  }
  printf("%ld\n", ans);
  return 0;
}
