#include <bits/stdc++.h>
using namespace std;
int a[100000];
int n, k;
int ans;
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &(a[i]));
  }
  int first = 0, last = 0;
  int mr = 0, ml = k - 1, msum = 0;
  int minr = 0, minl = k - 1, minsum = 0;
  for (int i = 0; i < k; i++) {
    msum += a[i];
    minsum = msum;
  }
  for (int i = k; i < n; i++) {
    int mconpa = msum;
    int minconpa = minsum;
    minconpa = minconpa - a[0] + a[i];
    mconpa = mconpa - a[0] + a[i];
    if (mconpa > msum) {
      msum = mconpa;
      mr = i - k + 1;
      ml = i;
    }
    if (minconpa < minsum) {
      minsum = minconpa;
      minr = i - k + 1;
      minl = i;
    }
  }
  if (abs(msum) > abs(minsum)) {
    ans = msum;
    for (int i = 0; i < n; i++) {
      if (i >= mr && ml >= i)
        ans += a[i];
      else {
        if (a[i] > 0) {
          ans += a[i];
        }
      }
    }
  } else {
    ans = 0;
    for (int i = 0; i < n; i++) {
      if (i >= minr && minl >= i)
        continue;
      else {
        if (a[i] > 0) {
          ans += a[i];
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
