#include <bits/stdc++.h>
using namespace std;
long long a[100010];
long long sum[100010];
int main() {
  bool flag = false;
  int checkA = 0, checkB = 0;
  long long ret = 0;
  long long n, k;
  cin >> n >> k;
  for (int(i) = (0); (i) < (n); ++i) {
    cin >> a[i + 1];
    sum[i + 1] = sum[i] + a[i + 1];
    if (a[i + 1] > 0) {
      checkB = 0;
      checkA++;
      ret += a[i + 1];
    } else if (a[i + 1] < 0) {
      checkA = 0;
      checkB--;
    } else {
      checkA++;
      checkB++;
    }
    if (checkA == k || checkB == k) flag = true;
  }
  if (flag) {
    cout << ret << endl;
    return 0;
  }
  pair<pair<int, int>, long long> ma =
      make_pair(make_pair(0, 0), -1000000000000000);
  pair<pair<int, int>, long long> mi =
      make_pair(make_pair(0, 0), 1000000000000000);
  for (int(i) = (0); (i) < (n - k + 1); ++i) {
    long long tmp = sum[i + k] - sum[i];
    if (ma.second < tmp) {
      ma.second = tmp;
      ma.first.first = i + 1;
      ma.first.second = i + k;
    }
    if (mi.second > tmp) {
      mi.second = tmp;
      mi.first.first = i + 1;
      mi.first.second = i + k;
    }
  }
  long long ans = -1000000000000000;
  long long hi = 0;
  for (int i = 1; i <= n; i++) {
    if (i < ma.first.first || i > ma.first.second) {
      if (a[i] > 0) hi += a[i];
    } else {
      hi += a[i];
    }
  }
  ans = max(ans, hi);
  hi = 0;
  for (int i = 1; i <= n; i++) {
    if (i < mi.first.first || i > mi.first.second) {
      if (a[i] > 0) hi += a[i];
    }
  }
  ans = max(ans, hi);
  cout << max(ans, 0ll) << endl;
  return 0;
}
