#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
bool prime(long long x) {
  for (long long i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) return false;
  }
  return true;
}
long long n, k, a[100010];
long long ta, mu, rin, ans;
signed main() {
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > 0) ta += a[i];
  }
  for (long long i = 0; i < n; i++) {
    if (i <= k - 1) {
      if (a[i] > 0) mu += a[i];
      rin += a[i];
    } else {
      if (a[i - (k - 1)] > 0) mu -= a[i - (k - 1)];
      rin -= a[i - (k - 1)];
      if (a[i] > 0) mu += a[i];
      rin += a[i];
    }
    if (i > k - 2) ans = max({ans, ta + rin - mu, ta - mu});
    ;
  }
  cout << ans << endl;
}
