#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, k;
long long ans;
int a[maxn];
long long s[maxn];
long long g[maxn];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    s[i] = s[i - 1] + (long long)a[i];
    g[i] = g[i - 1] + (long long)max(a[i], 0);
  }
  ans = 0;
  for (int i = 1; i + k - 1 <= n; i++)
    ans = max(ans, max((long long)0, s[i + k - 1] - s[i - 1]) + g[n] -
                       g[i + k - 1] + g[i - 1] - g[0]);
  printf("%I64d\n", ans);
  return 0;
}
