#include <bits/stdc++.h>
using namespace std;
int N, K;
long long a[100000], plusWA[100000], allWA[100000];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(9);
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> a[i];
  plusWA[0] = 0;
  allWA[0] = 0;
  for (int i = 0; i < N; i++) {
    plusWA[i + 1] = plusWA[i];
    plusWA[i + 1] += max((long long)0, a[i]);
    allWA[i + 1] = allWA[i] + a[i];
  }
  long long ans = 0;
  for (int i = 0; i < N - K + 1; i++) {
    long long tmp = plusWA[i] + max((long long)0, allWA[i + K] - allWA[i]) +
                    plusWA[N] - plusWA[i + K];
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
