#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  long long a[n];
  long long sum[n + 1];
  sum[0] = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
  }
  long long ys[n + 1];
  ys[0] = 0;
  for (long long i = 0; i < n; i++) {
    if (a[i] > 0) {
      ys[i + 1] = ys[i] + a[i];
    } else
      ys[i + 1] = ys[i];
  }
  long long ans = 0;
  for (long long i = 0; i < n - k + 1; i++) {
    long long ss = ys[n] - ys[i + k] + ys[i] - ys[0];
    long long kk = max(sum[i + k] - sum[i], -sum[i + k] + sum[i]);
    ans = max(ans, ss + kk);
  }
  cout << ans << endl;
}
