#include <bits/stdc++.h>
using namespace std;
int n, k, a[100005], s1[100005], s2[100005];
long long ans = -1e12;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    s1[i] = s1[i - 1] + a[i];
    s2[i] = s2[i - 1];
    if (a[i] >= 0) s2[i] += a[i];
  }
  for (int i = 1; i <= n - k + 1; i++) {
    long long t1 = s1[i + k - 1] - s1[i - 1],
              t2 = s2[i - 1] + s2[n] - s2[i + k - 1];
    if (t1 >= 0) t2 += t1;
    ans = max(ans, t2);
  }
  printf("%lld", ans);
  return 0;
}
