#include <bits/stdc++.h>
using namespace std;
const int mnx = 1e6 + 9;
const int mod = 1e9 + 7;
long long n, k;
long long a[mnx];
long long suff[mnx];
long long pref[mnx];
long long b[mnx];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i + 1] = b[i] + a[i];
    pref[i + 1] = pref[i] + max(a[i], 0LL);
  }
  long long res = -1;
  for (int i = 1; i <= n - k + 1; i++) {
    res =
        max(res, pref[n] - (pref[i + k] - pref[i]) + max(0LL, b[i + k] - b[i]));
  }
  cout << res << '\n';
  return 0;
}
