#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, d = 0, e = 0, r = 0, s = 0, t = 0, u = 0;
  cin >> n >> k;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i < k) {
      s += a[i];
      r += max((long long)0, a[i]);
      t = s;
      u = r;
    } else {
      s -= a[i - k];
      s += a[i];
      r -= max((long long)0, a[i - k]);
      r += max((long long)0, a[i]);
      if (t < s) {
        t = s;
        d = i - k + 1;
      }
      if (u > r) {
        u = r;
        e = i - k + 1;
      }
    }
  }
  r = 0;
  for (int i = 0; i < e; i++) r += max((long long)0, a[i]);
  for (int i = e + k; i < n; i++) r += max((long long)0, a[i]);
  for (int i = 0; i < d; i++) t += max((long long)0, a[i]);
  for (int i = d + k; i < n; i++) t += max((long long)0, a[i]);
  cout << max(u + r, t);
}
