#include <bits/stdc++.h>
using namespace std;
constexpr long long INF = (1LL << 55);
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  vector<long long> cum(n + 1, 0), pcum(n + 1, 0);
  for (int i = 0; i < n; i++) {
    cum[i + 1] = cum[i] + a[i];
    if (a[i] > 0) pcum[i + 1] = pcum[i] + a[i];
  }
  long long res = -INF;
  for (int i = 0; i + k <= n; i++) {
    int r = i + k;
    long long tmp = max(0LL, cum[r] - cum[i]);
    tmp += pcum[i] + pcum[n] - pcum[r];
    res = max(res, tmp);
  }
  cout << res << endl;
  return 0;
}
