#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<long long> plus(n + 1, 0);
  for (int i = 0; i < n; ++i) plus[i + 1] = plus[i] + (a[i] > 0 ? a[i] : 0);
  vector<long long> ksum(n + 1, 0);
  for (int i = 0; i < k; ++i) ksum[k] += a[i];
  for (int i = k; i < n; ++i) {
    ksum[i + 1] = ksum[i] + a[i] - a[i - k];
  }
  long long ans = 0;
  for (int i = k; i < n + 1; ++i) {
    long long tmp = 0;
    tmp = ksum[i];
    tmp += plus[n] - plus[i];
    tmp += plus[i - k];
    ans = (ans >= tmp ? ans : tmp);
  }
  for (int i = k; i < n + 1; ++i) {
    long long tmp = 0;
    tmp += plus[i] - plus[i - k];
    ans = (ans >= tmp ? ans : tmp);
  }
  cout << ans << endl;
}
