#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 123456;
int n, k, a[MAX_N];
long long partialk[MAX_N], positive_sum[MAX_N];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (i == 0)
      positive_sum[i] = max(a[i], 0);
    else
      positive_sum[i] = positive_sum[i - 1] + max(a[i], 0);
  }
  int max_sum, black_k, white_k;
  for (int i = 0; i < k; ++i) partialk[0] += a[i];
  black_k = partialk[0] + positive_sum[n - 1] - positive_sum[k - 1];
  white_k = positive_sum[n - 1] - positive_sum[k - 1];
  max_sum = max(black_k, white_k);
  for (int i = k; i < n; ++i) {
    partialk[i - k + 1] = partialk[i - k] + a[i] - a[i - k];
    black_k = partialk[i - k + 1] + positive_sum[n - 1] - positive_sum[i] +
              positive_sum[i - k];
    white_k = positive_sum[n - 1] - positive_sum[i] + positive_sum[i - k];
    if (max(black_k, white_k) > max_sum) max_sum = max(black_k, white_k);
  }
  cout << max_sum << endl;
  return 0;
}
