#include <bits/stdc++.h>
int main(void) {
  int loop1, loop2;
  int how_data;
  int can;
  scanf("%d %d\n", &how_data, &can);
  long long int data[how_data];
  int data_flag[how_data];
  long long int max = 0;
  for (loop1 = 0; loop1 < how_data; loop1++) {
    scanf("%lld", &data[loop1]);
    if (data[loop1] > 0)
      data_flag[loop1] = 1;
    else
      data_flag[loop1] = 0;
    if (data[loop1] >= 0) max += data[loop1];
  }
  int ren = 0;
  int mae = 2;
  int end = 0;
  for (loop1 = 0; loop1 < how_data; loop1++) {
    if (mae == data_flag[loop1] || data[loop1] == 0) {
      ren++;
      if (ren == can) {
        end = 1;
      }
    } else
      ren = 0;
    mae = data_flag[loop1];
  }
  mae = 0;
  ren = 0;
  long long int s_max;
  long long int k_max;
  long long int max2 = -1000000000000000;
  if (end == 0) {
    for (loop1 = 0; loop1 < how_data - can + 1; loop1++) {
      s_max = max;
      for (loop2 = loop1; loop2 < loop1 + can; loop2++) {
        if (data[loop2] >= 0) s_max -= data[loop2];
      }
      k_max = s_max;
      for (loop2 = loop1; loop2 < loop1 + can; loop2++) {
        k_max += data[loop2];
      }
      if (k_max > max2) max2 = k_max;
      if (s_max > max2) max2 = s_max;
    }
  }
  if (end == 1)
    printf("%lld\n", max);
  else
    printf("%lld\n", max2);
  return 0;
}
