#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string &str, char sep) {
  std::vector<std::string> v;
  auto first = str.begin();
  while (first != str.end()) {
    auto last = first;
    while (last != str.end() && *last != sep) ++last;
    v.push_back(std::string(first, last));
    if (last != str.end()) ++last;
    first = last;
  }
  return v;
}
int n, k;
int a[100000];
int b[100001];
int c[100001];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  b[0] = c[0] = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > 0)
      b[i + 1] = b[i] + a[i];
    else
      b[i + 1] = b[i];
    c[i + 1] = c[i] + a[i];
  }
  int ans = 0;
  for (int i = 0; i < n - k + 1; i++) {
    ans = max(ans, b[i] + max(0, c[i + k] - c[i]) + b[n] - b[i + k]);
  }
  cout << ans << endl;
  return 0;
}
