#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def readln(ch):
    _res = list(map(int,str(input()).split(ch)))
    return _res

s = readln(' ')
n,k = s[0],s[1]
a = [0 for i in range(0,n+1)]
a[1:] = readln(' ')
s = a[:]
r = a[:]
for i in range(1,n+1):
    s[i] = s[i-1] + s[i]
    if r[i] > 0:
        r[i] = r[i-1] + r[i]
    else:
        r[i] = r[i-1]

ans = 0
for i in range(k,n+1):
    ans = max(ans,r[n] - (r[i] - r[i-k]) + max(0,s[i] - s[i-k]))

print(ans)
