#include <bits/stdc++.h>
using namespace std;
int n, k, a[100002];
long long s1[100002], s2[100002], ans;
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] + max(0, a[i]);
  }
  ans = max(s1[n] - s1[n - k], 0ll) + s2[n - k];
  for (int i = n; i > k; i--) {
    a[i] = max(0, a[i]);
    ans = max(ans, s2[i - k - 1] + max(s1[i - 1] - s1[i - k - 1], 0ll) + a[i]);
  }
  printf("%lld", ans);
}
