#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1LL << 60;
int MOD = 1000000007;
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  std::vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  std::vector<long long> rskw(n);
  rskw[0] = a[0];
  for (int i = 1; i < n; i++) rskw[i] = rskw[i - 1] + a[i];
  std::vector<long long> best_rskw(n);
  if (a[0] <= 0)
    best_rskw[0] = 0;
  else
    best_rskw[0] = a[0];
  for (int i = 1; i < n; ++i) {
    if (a[i] <= 0)
      best_rskw[i] = best_rskw[i - 1];
    else
      best_rskw[i] = best_rskw[i - 1] + a[i];
  }
  long long ans = -INF;
  for (int i = 0; i < n - k + 1; i++) {
    long long left = 0LL;
    long long right = 0LL;
    long long mid = rskw[i + k - 1];
    if (i != 0) left = best_rskw[i - 1];
    right = best_rskw[n - 1] - best_rskw[i + k - 1];
    if (i != 0) mid -= rskw[i - 1];
    ans = max(ans, left + right + mid);
  }
  cout << ans << endl;
  return 0;
}
