#include <bits/stdc++.h>
using namespace std;
int n, k;
long long s[100004], ss[100004];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    s[i] = s[i - 1] + x;
    ss[i] = ss[i] + max(0ll, x);
  }
  long long ans = max(0ll, s[n]);
  for (int i = k; i <= n; i++) {
    int j = i - k + 1;
    ans = max(ans, ss[n] - (ss[i] - ss[j - 1]) + max(0ll, s[i] - s[j - 1]));
  }
  cout << ans;
}
