#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  int64_t a[100010] = {};
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
  }
  int64_t sum[100010] = {};
  for (int i = 1; i <= N + 1; i++) {
    sum[i] = sum[i - 1] + a[i];
  }
  int64_t lef[100010] = {};
  int64_t rig[100010] = {};
  for (int i = 1; i <= N + 1; i++) {
    if (a[i] > 0) {
      lef[i] = lef[i - 1] + a[i];
    } else {
      lef[i] = lef[i - 1];
    }
  }
  for (int i = N; i >= 0; i--) {
    if (a[i] > 0) {
      rig[i] = rig[i + 1] + a[i];
    } else {
      rig[i] = rig[i - 1];
    }
  }
  int64_t res = 0;
  for (int i = 1; i <= N + 1 - K; i++) {
    int64_t tmp = sum[i + K - 1] - sum[i - 1];
    if (tmp > 0) {
      res = max(res, tmp + lef[i - 1] + rig[i + K]);
    } else {
      res = max(res, lef[i - 1] + rig[i + K]);
    }
  }
  cout << res << endl;
  return 0;
}
