#include <bits/stdc++.h>
using namespace std;
const long long INF = 1001001001001001001;
vector<long long> D;
long long N, K;
long long a[100002];
long long wa[100002];
long long miwa[100002];
long long plwa[100002];
long long Kwa[100002];
long long miKwa[100002];
long long plKwa[100002];
signed main() {
  scanf("%lld %lld", &N, &K);
  for (long long i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  long long large = 0, largen = -1;
  long long small = 0, smallen = -1;
  for (long long i = 0; i < N; i++) {
    if (i == 0) {
      wa[i] = a[i];
      miwa[i] = min((long long)0, a[i]);
      plwa[i] = max((long long)0, a[i]);
    } else {
      wa[i] = a[i] + wa[i - 1];
      miwa[i] = min((long long)0, a[i]) + miwa[i - 1];
      plwa[i] = max((long long)0, a[i]) + plwa[i - 1];
    }
    if (i >= K - 1) {
      if (i - K >= 0)
        Kwa[i] = wa[i] - wa[i - K];
      else
        Kwa[i] = wa[i];
      if (i - K >= 0)
        miKwa[i] = miwa[i] - miwa[i - K];
      else
        miKwa[i] = miwa[i];
      if (i - K >= 0)
        plKwa[i] = plwa[i] - plwa[i - K];
      else
        plKwa[i] = plwa[i];
      if (plKwa[i] >= large) {
        large = plKwa[i];
        largen = i;
      }
      if (miKwa[i] <= small) {
        small = miKwa[i];
        smallen = i;
      }
    }
  }
  long long ans1 = 0, ans2 = 0;
  if (largen)
    for (long long i = 0; i < N; i++) {
      if (i == largen - K + 1) {
        ans1 += Kwa[largen];
        i = largen;
      } else
        ans1 += max(a[i], (long long)0);
    }
  if (smallen)
    for (long long i = 0; i < N; i++) {
      if (i == smallen - K + 1) {
        ;
        i = smallen;
      } else
        ans2 += max(a[i], (long long)0);
    }
  printf("%lld\n", max(ans1, ans2));
}
