#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, m;
int a[N];
long long ans = 0ll, minn = 0ll, anss = 0ll;
int main() {
  scanf("%d%d", &n, &m);
  for (int k = 1; k <= n; k++) {
    scanf("%d", &a[k]);
    if (a[k] > 0) ans += a[k], anss += a[k];
  }
  for (int k = 1; k <= m; k++) minn += a[k];
  long long maxx = minn;
  long long x = minn;
  int u = m, v = m;
  for (int k = m; k <= n; k++) {
    x = x + a[k] - a[k - m];
    if (x < minn) {
      minn = min(minn, x);
      u = k;
    }
    if (x > maxx) {
      maxx = max(maxx, x);
      v = k;
    }
  }
  for (int k = u; k > u - m; k--)
    if (a[k] > 0) ans -= a[k];
  for (int k = v; k > v - m; k--)
    if (a[k] < 0) anss += a[k];
  printf("%lld", max(ans, anss));
  return 0;
}
