#include <bits/stdc++.h>
using namespace std;
int p[100010], n, k;
int d[2][100010];
long long s[100010];
void solve() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", p + i);
  for (int i = 1; i <= n; i++) d[0][i] = d[0][i - 1] + max(0, p[i]);
  for (int i = n; i; i--) d[1][i] = d[1][i + 1] + max(0, p[i]);
  for (int i = 1; i <= n; i++) s[i] = s[i - 1] + p[i];
  long long ans = 0;
  for (int i = 1; i + k - 1 <= n; i++) {
    ans =
        max(ans, d[0][i - 1] + d[1][i + k] + max(0LL, s[i + k - 1] - s[i - 1]));
  }
  printf("%lld", ans);
}
int main() {
  int Tc = 1;
  for (int tc = 1; tc <= Tc; tc++) {
    solve();
  }
  return 0;
}
