#include <bits/stdc++.h>
using namespace std;
const long long N = (int)1e5 + 7;
const int INF = (int)1e9 + 7;
long long n, k, l, r, A, ans;
long long a[N], b[N], c[N];
int main() {
  scanf("%I64d %I64d", &n, &k);
  for (long long i = 0; i < n; i++) {
    scanf("%I64d", &a[i]);
  }
  b[0] = a[0];
  c[0] = max(0LL, a[0]);
  for (long long i = 1; i < n; i++) {
    b[i] = b[i - 1] + a[i];
    c[i] = c[i - 1] + max(0LL, a[i]);
  }
  ans = c[n - 1] - c[k - 1] + max(0LL, b[k - 1]);
  for (long long i = 1; i <= n - k; i++) {
    A = b[i + k - 1] - b[i - 1];
    A = (A < 0 ? 0 : A);
    l = c[i - 1], r = c[n - 1] - c[i + k - 1];
    ans = max(ans, max(0LL, A) + l + r);
  }
  printf("%I64d", ans);
}
