#include <bits/stdc++.h>
using namespace std;
long long a[100010];
long long b[100010];
long long as[100010];
long long bs[100010];
long long sum(int l, int r, long long* s) { return s[r] - s[l]; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    b[i] = max(0LL, a[i]);
    as[i + 1] = as[i] + a[i];
    bs[i + 1] = bs[i] + b[i];
  }
  long long ans = 0;
  for (int i = 0; i < N - K + 1; i++) {
    long long l = sum(0, i, bs);
    long long c = max(0LL, sum(i, i + K, as));
    long long r = sum(i + K, N, bs);
    ans = l + c + r;
  }
  cout << ans << endl;
}
