def getlist():
	return list(map(int, input().split()))

con = 1000000007

#処理内容
def main():
	N, K = getlist()
	a = getlist()
	b = [0] * (N + 1)
	c = [0] * (N + 1)
	for i in range(1, N + 1):
		b[i] = b[i - 1] + a[i - 1]
		if a[i - 1] >= 0:
			c[i] = c[i - 1] + a[i - 1]
		else:
			c[i] = c[i - 1]

	#計算
	ans = 0
	for i in range(N - K + 1):
		val = max(0, b[i + K] - b[i]) + c[i] + (c[N] - c[i + K])
		ans = max(ans, val)
	print(ans)



if __name__ == '__main__':
	main()