from numpy import*

def section_sum(numbers,separate):
    sep1=array(numbers[separate:],dtype=int)
    sep2=array(numbers[:-separate],dtype=int)
    sep3=sum(numbers[:separate])
    return [max(i,0)for i in insert(sep3+cumsum(sep1-sep2),0,sep3)]

n,k,*a=map(int,open(0).read().split())
l=[]
for s,t in sorted(enumerate(section_sum(a,k)),key=lambda x:x[1],reverse=1)[:10]:
    x=array(a[:s]+a[s+k:])
    l.append(t+sum(x[x>0]))
print(int(max(l)))