#include <bits/stdc++.h>
using namespace std;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n + 1, 0);
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  vector<long long> v(n + 1, 0);
  vector<long long> black(n + 1, 0);
  for (long long i = 1; i <= n; i++) {
    v[i] = v[i - 1] + a[i];
    black[i] = black[i - 1] + max(0LL, a[i]);
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (i + k > n) break;
    ans = max(ans, black[i] + (black[n] - black[i + k]));
    ans = max(ans, black[i] + (v[i + k] - v[i]) + (black[n] - black[i + k]));
  }
  cout << ans << endl;
  return 0;
}
