#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, k, a[100010];
  cin >> n >> k;
  for (int i = (int)0; i < (int)n; ++i) cin >> a[i];
  long long sum = 0;
  for (int i = (int)0; i < (int)n; ++i) {
    if (a[i] > 0) sum += a[i];
  }
  long long retw = 0, retb = 0, minret = -0x3f3f3f;
  for (int i = (int)0; i < (int)k - 1; ++i) {
    if (a[i] > 0) retw += a[i];
    if (a[i] < 0) retb += a[i];
  }
  for (int i = (int)k - 1; i < (int)n; ++i) {
    if (a[i] > 0) retw += a[i];
    if (a[i] < 0) retb += a[i];
    minret = max(minret, -1 * retw);
    minret = max(minret, retb);
    if (a[i - k + 1] > 0) retw -= a[i - k + 1];
    if (a[i - k + 1] < 0) retb -= a[i - k + 1];
  }
  cout << sum + minret << endl;
  return 0;
}
