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

int main() {
  int n, k;
  cin >> n >> k;

  vector<long long> a(n + 1), r(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (a[i] > 0) r[i] = a[i];
  }

  for (int i = 1; i <= n; ++i) {
    r[i] += r[i - 1];
    a[i] += a[i - 1];
  }

  long long ans = -1001001001001001;
  for (int i = 0; i + k <= n; ++i) {
    ans = max(ans, r[i] + max(0ll, a[i + k] - a[i]) + r[n] - r[i + k]);
  }

  cout << ans << endl;
}
