#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,k=map(int,input().split())\n"
"a=[0]+list(map(int,input().split()))\n"
"s=[0]\n"
"p=[0]\n"
"for i in range(1,n+1):\n"
"  s.append(s[i-1]+a[i])\n"
"  p.append(p[i-1]+max(0,a[i]))\n"
"ans=0\n"
"for i in range(1,n-k+2):\n"
"  t=max(0,s[i+k-1]-s[i-1])\n"
"  t+=p[i-1]+p[n]-p[i+k-1]\n"
"  ans=max(ans,t)\n"
"print(ans)\n"
"\"";
  system(s);
  return 0;
}            