#include <bits/stdc++.h>
using namespace std;
long long int A[200000];
long long int n, k, frontcount = 0;
int large() {
  long long int m = frontcount, cur = frontcount, j = 0;
  for (int i = k; i < n; ++i) {
    cur = cur + A[i] - A[i - k];
    if (m < cur) j = i - k + 1, m = cur;
  }
  return j;
}
int small() {
  long long int m = frontcount, cur = frontcount, j = 0;
  for (int i = k; i < n; ++i) {
    cur = cur + A[i] - A[i - k];
    if (m > cur) j = i - k + 1, m = cur;
  }
  return j;
}
long long int sum = 0;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &A[i]);
  }
  for (int i = 0; i < k; ++i) {
    frontcount += A[i];
  }
  int l = large(), s = small();
  for (int i = 0; i < n; ++i) {
    if (i >= l && i < l + k) {
      sum += A[i];
    } else {
      sum += A[i] > 0 ? A[i] : 0;
    }
  }
  long long int stay = 0;
  for (int i = 0; i < n; ++i) {
    if (i >= s && i < s + k) {
      continue;
    } else {
      stay += A[i] > 0 ? A[i] : 0;
    }
  }
  printf("%lld", max(stay, sum));
}
