#include <bits/stdc++.h>
using namespace std;
const long long INF = 2e18;
const long long MOD = 1e9 + 7;
long long N, K;
long long a[100010];
long long plusSum = 0;
int main() {
  cin >> N >> K;
  for (long long i = 0; i < N; i++) {
    cin >> a[i];
    if (a[i] > 0) {
      plusSum += a[i];
    }
  }
  long long ans = 0;
  long long l = 0, r = K;
  long long minusSum = 0;
  for (long long i = l; i < r; i++) {
    if (a[i] < 0) {
      minusSum += a[i];
    }
  }
  while (r <= N) {
    while (a[r] >= 0 && r <= N) {
      r++;
    }
    while (r - l >= K + 1) {
      ans = max(ans, plusSum + minusSum);
      if (a[l] < 0) {
        minusSum -= a[l];
      }
      l++;
    }
    if (r == N) break;
    minusSum += a[r];
    r++;
  }
  cout << ans << endl;
  return 0;
}
