#include <bits/stdc++.h>
using namespace std;
int cum[100010], cum_p[100010];
int main(void) {
  int n, k;
  scanf("%d%d", &n, &k);
  vector<int> a(n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) {
    cum[i + 1] = cum[i] + a[i];
    cum_p[i + 1] = cum_p[i] + max(0, a[i]);
  }
  long long ans = -(long long)1e15;
  for (int i = 0; i <= n - k; i++) {
    long long res = (cum_p[i] - cum_p[0]) + max(0, cum[i + k] - cum[i]) +
                    (cum_p[n] - cum_p[i + k]);
    ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}
