#b
#from itertools import accumulate
n, k  = [int(i) for i in input().split()]
a     = [int(i) for i in input().split()]

plus,minus = [0],[0] #initialize for the beginning
plus_accumulate  = 0
minus_accumulate = 0

for v in a:
    if v>=0:
        plus_accumulate += v
    else:
        minus_accumulate += abs(v) #-1*v
    plus.append(plus_accumulate)
    minus.append(minus_accumulate)    
        
minimum_lost = 10**18
for i in range(n-k+1):
    black_lost = minus[i+k] - minus[i]
    white_lost = plus[i+k] - plus[i]
    minimum_lost = min(minimum_lost, black_lost, white_lost)

print(plus_accumulate - minimum_lost)