#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = ((ans % m) * (a % m)) % m;
    b /= 2;
    a = ((a % m) * (a % m)) % m;
  }
  return ans % m;
}
long long cf[5005];
long long ps[5005];
long long a[5005];
long long sum;
long long ans;
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    cf[i] = a[i];
    cf[i] += cf[i - 1];
    if (a[i] > 0) ps[i] = a[i];
    ps[i] += ps[i - 1];
    if (a[i] > 0) sum += a[i];
  }
  for (int i = 1; i <= n; i++) {
    if (i + k - 1 > n) break;
    long long temp = cf[i + k - 1] - cf[i - 1];
    temp += (sum - (ps[i + k - 1] - ps[i - 1]));
    ans = max(ans, temp);
    temp = 0;
    temp += (sum - (ps[i + k - 1] - ps[i - 1]));
    ans = max(ans, temp);
  }
  cout << ans;
}
