#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 100000, INF = 0x3f3f3f3f3f;
long long a[MAXN + 5], sum1[MAXN + 5], sum2[MAXN + 5];
long long n, k, Min = INF, Max = -INF, temp;
int main() {
  scanf("%lld%lld", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    if (a[i] >= 0) {
      sum1[i] = sum1[i - 1] + a[i];
      sum2[i] = sum2[i - 1];
    } else {
      sum1[i] = sum1[i - 1];
      sum2[i] = sum2[i - 1] + a[i];
    }
    if (i >= k) {
      temp = sum1[i] - sum1[i - k];
      Min = min(Min, temp);
      temp = sum2[i] - sum2[i - k];
      Max = max(Max, temp);
    }
  }
  printf("%lld\n", max(sum1[n] + Max, sum1[n] - Min));
  return 0;
}
