#include <bits/stdc++.h>
using namespace std;
long long N, K;
long long a[100005];
long long maxi(long long left, long long right) {
  long long ret = 0;
  for (int i = left; i <= right; i++) {
    if (a[i] > 0) {
      ret += a[i];
    }
  }
  return ret;
}
long long getsum(long long left, long long right) {
  long long ret = 0;
  for (int i = left; i <= right; i++) {
    ret += a[i];
  }
  return ret;
}
int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  long long ans = -1 * INT_MAX;
  for (int start = 0; start <= N - K; start++) {
    long long sumi = 0;
    sumi = max(sumi, getsum(start, start + K - 1));
    sumi += maxi(0, start - 1);
    sumi += maxi(start + K, N - 1);
    ans = max(ans, sumi);
  }
  cout << ans << endl;
}
