#include <bits/stdc++.h>
using namespace std;
const long long N = (int)1e5 + 7;
const int INF = (int)1e9 + 7;
long long sm[N], po[N];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vector<long long> v(n);
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &v[i]);
  }
  for (int i = 0; i < n; i++) {
    sm[i + 1] = sm[i] + v[i];
  }
  for (int i = 0; i < n; i++) {
    po[i + 1] = po[i] + max(v[i], 0LL);
  }
  long long ans = 0;
  for (int i = 0; i < n - k + 1; i++) {
    int l = i;
    int r = i + k;
    long long other = po[l] + (po[n] - po[r]);
    long long cur = sm[r] - sm[l];
    ans = max(ans, other + max(cur, 0LL));
  }
  printf("%I64d", ans);
}
