#include <cstdio>
#include <algorithm>
using namespace std;
int n,m,i,a[100100];
long long c[100100],s[100100],r;
int main() {
  scanf("%d%d",&n,&m);
  for (i=1; i<=n; i++) {
    scanf("%d",&a[i]);
    s[i]=s[i-1]+a[i];
    c[i]=c[i-1]+max(a[i],0);
  }
  for (i=1; i+m-1<=n; i++) r=max(r,c[i-1]+c[n]-c[i+m-1]+max(0LL,s[i+m-1]-s[i-1]));
  printf("%lld\n",r);
  return 0;
}
