#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long b[n + 1], c[n + 1];
  b[0] = c[0] = 0;
  for (int i = 0; i < n; i++) {
    b[i + 1] = b[i] + a[i];
    c[i + 1] = c[i] + max(0, a[i]);
  }
  long long res = 0;
  for (int i = 0; i < n - k + 1; i++) {
    res = max(res, c[i] - c[0] + c[n] - c[i + k]);
    res = max(res, c[i] - c[0] + c[n] - c[i + k] + b[i + k] - b[i]);
  }
  cout << res << "\n";
  return 0;
}