#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e15;
const long long int MOD = 1e9 + 7;
signed main() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> a(n);
  for (long long int i = 0; i < (n); ++i) cin >> a[i];
  vector<long long int> x(n + 1), y(n + 1);
  for (long long int i = 1; i <= n; i++) {
    x[i] = x[i - 1] + a[i - 1];
    y[i] = y[i - 1] + max(0LL, a[i - 1]);
  }
  long long int ans = 0;
  for (long long int i = 0; i < n - k; i++) {
    long long int tmp = max(0LL, x[i + k] - x[i]);
    tmp += y[i] - y[0] + y[n] - y[i + k];
    if (tmp > ans) {
      ans = tmp;
    }
  }
  cout << ans << endl;
  return 0;
}
