#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main() {
  int n, k;
  cin >> n >> k;
  ll a[n];
  ll msum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    msum += max(1LL * 0, a[i]);
  }
  ll ans = -LLONG_MAX;
  for (int i = 0; i <= n - k; i++) {
    ll tmp1 = 0, tmp2 = 0;
    for (int j = 0; j < k; j++) {
      tmp1 += a[i + j];
      tmp2 += max(1LL * 0, a[i + j]);
    }
    ll tmp = 0;
    if (tmp1 >= 0) {
      tmp = tmp1 + (msum - tmp2);
    } else {
      tmp = msum - tmp2;
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
