#include <bits/stdc++.h>
using namespace std;
long long n, m, i, j, a[200005], pre[200005], suf[200005], ans;
int main() {
  scanf("%lld%lld", &n, &m);
  for ((i) = 1; (i) <= (n); (i)++) {
    scanf("%lld", &a[i]);
    pre[i] = pre[i - 1] + max(a[i], 0ll);
  }
  for ((i) = (n); (i) >= 1; (i)--) {
    suf[i] = suf[i + 1] + max(a[i], 0ll);
  }
  for ((i) = 1; (i) <= (n); (i)++) {
    a[i] += a[i - 1];
  }
  for ((i) = 1; (i) <= (n - m + 1); (i)++) {
    ans = max(ans, a[i + m - 1] - a[i - 1] + pre[i - 1] + suf[i + m]);
  }
  cout << ans << endl;
  return 0;
}
