#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 7;
const int N = (int)1e5 + 7;
long long sum[N];
long long pref[N];
long long suf[N];
long long a[N];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%I64d", a + i);
  }
  for (int i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + a[i];
  }
  for (int i = 0; i < n; i++) {
    pref[i + 1] = pref[i] + max(0LL, a[i]);
  }
  for (int i = n - 1; i >= 0; i--) {
    suf[i] = suf[i + 1] + max(0LL, a[i]);
  }
  long long ans = 0;
  for (int i = 0; i + k <= n; i++) {
    ans = max(ans, pref[i] + suf[i + k] + max(0LL, sum[i + k] - sum[i]));
  }
  cout << ans;
}
