#include <bits/stdc++.h>
using namespace std;
const int N = 100500;
long long A[N];
long long S[N];
long long Sp[N];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &A[i]);
    S[i + 1] = S[i] + A[i];
    Sp[i + 1] = Sp[i] + ((A[i] >= 0) ? A[i] : 0);
  }
  long long ans = 0;
  for (int i = 0; i + k <= n; i++) {
    long long cur = S[i + k] - S[i];
    long long l = Sp[i];
    long long r = Sp[n] - Sp[i + k];
    ans = max(ans, l + cur + r);
  }
  printf("%lld\n", ans);
}
