Go: package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	parseProblem(os.Stdin)
}

func parseProblem(r io.Reader) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	for true {
		n, k := scanInt(sc), scanInt(sc)
		if n == 0 && k == 0 {
			break
		}
		sum := make([]int, n+2)
		for i := 2; i <= n+1; i++ {
			sum[i] = sum[i-1] + scanInt(sc)
		}
		max := math.MinInt32
		for i := 1; i+k <= n+1; i++ {
			if v := sum[i+k] - sum[i]; max < v {
				max = v
			}
		}
		fmt.Println(max)
	}
	return
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

Python: while True:
    n, k = map(int, input().split())
    
    if n==0 and k==0 :
        break
    
    slist = []
    alist = []
    s = 0
    for i in range(k):
        a = int(input())
        alist.append(a)
        s += a
    slist.append(s)
    
    for i in range(n-k):
        a = int(input())
        alist.append(a)
        s = slist[i]+a-alist[i]
        slist.append(s)
    
    print(max(slist))
    continue

Python: from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    while True:
        n, m = map(int, input().split())
        if [n, m] == [0, 0]:
            break
        else:
            A = [int(input()) for i in range(n)]
            B = [0] + A
            # 累積和を格納したリスト．A[l:r]の総和はB[r] - B[l]
            B = list(accumulate(B))

            val = max([B[i + m] - B[i] for i in range(n - m + 1)])
            print(val)

resolve()

Python: while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    a=[]
    for i in range (n):
        a.append(int(input()))
        c=0
    for i in range(k):
        c+=a[i]
        b=c
    for i in range(k,n):
        c+=a[i]
        c-=a[i - k]
        b=max(b,c)
    print(b)

Python: while True:
    n,k = map(int,input().split())
    if (n,k) == (0,0):
        break
    a=[]
    for i in range(n):
        a.append(int(input()))
        c = 0
    for j in range(k):
        c += a[j]
        b = c
    for h in range(k,n):
        c += a[h]
        c -= a[h - k]
        b = max(b,c)
    print(b)

Python: #48 最大の和
while True:
        n, k = map(int, input().split())
        if n == k == 0:
                break
        
        a = [int(input()) for i in range(n)]
        s = sum(a[0:k])                         #リストaの0からkまでの和をsとする
        max = s                                 #maxにsを代入する
        for i in range(k,n):                    
                s = s + a[i] - a[i-k]           
                if s > max:                     #sがmaxより大きければmaxにsを代入する
                        max = s
        print(max)

Python: while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    a=[int(input()) for _ in range(n)]
    s=sum(a[0:k])
    ss=[s]
    for i in range(k,n):
        s=s+a[i]-a[i-k]
        ss.append(s)
    print(max(ss))

Python: while True :
    n,k = map(int,input().split())
    if n == 0 and k == 0 :
        break
    a = 0
    x = [ ]
    for i in range (n):
        y = int(input())
        x.append(y)
    b = 0
    for j in range (k):
        b += x[j]
    S = [ ]
    S.append(b)
    for i in range (1,n-k+1):
        b = S[i-1] + x[i+k-1] - x[i-1]
        S.append(b)
    print(max(S))

Python: while True:
    n,k=map(int,input().split())

    if n==k==0:
        break
    x=[int(input())]
    
    for i in range(n-1):
        y=int(input())
        x.append(x[i]+y)
    
    maxx=x[0]
    
    for i in range(n-k):
        maxx=max(maxx,x[i+k]-x[i])
    
    print(maxx)

Python: while True:
    n, k = map(int,input().split())
    if n == k == 0:
        break
    data = [int(input()) for _ in range(n)]
    s = sum(data[0:k])
    ss = [s]
    for i in range(k, n):
        s = s + data[i]- data[i-k]
        ss.append(s)
    print(max(ss))

Python: while 1:
	n,m=map(int,input().split())
	if n==n==0: break
	li=[]
	for i in range(n):
		li.append(int(input()))
	s_li=[li[0]]
	for i in range(1,n):
		s_li.append(s_li[-1]+li[i])
	c_li=[s_li[m-1]]
	for i in range(n-m):
		c_li.append(s_li[i+m]-s_li[i])
	print(max(c_li))

Python: a, s = [0]*100003, [0]*100003
while True:
	n, k = map(int, input().split())
	if n == 0: break
	s[0] = a[0] = int(input())
	for i in range(1, n):
		a[i] = int(input())
		s[i] = s[i-1] + a[i]
		if i >= k: s[i] -= a[i-k]
	ans = s[k-1]
	for i in range(k, n):
		if s[i] > ans: ans = s[i]
	print(ans)

Python: #0516
while True:
    x = 0
    a = []
    S = []
    s = 0
    cnt = 0
    n , k = map(int,input().split())
    if n == 0 and k == 0:
        break
    for i in range(n):
        a.append(int(input()))

    S.append(sum(a[0:k]))
    
    for j in range(k,n):
        s = S[cnt] - a[j - k] + a[j]
        S.append(s)
        cnt += 1
    
    print(max(S))

Python: while True:
 n,k = map(int,input().split())
 if n==0 and k==0: break
 
 a = [int(input()) for i in range(n)]

 s = sum(a[0:k])
 max = s

 for i in range(k,n):
  s = s+a[i]-a[i-k]
  if s > max: max = s
 
 print(max)

Python: s=0
while True:
    n,k = map(int, input().split())
    list = [int(input()) for i in range(n)]
    if n==0 and k==0:
        break
    a=sum(list[0:k])
    b=[a]
    for i in range(n-k):
        a += list[i+k]-list[i]
        b.append(a)
    print(max(b))

Python: while True:
    n,k = map(int,input().split())
    if n == 0 and k == 0:
        break
    a = [int(input()) for _ in range(n)]
    s = sum(a[0:k])
    ss = [s]
    for i in range(k,n):
        s = s + a[i] - a[i-k]
        ss.append(s)
    print(max(ss))

Python: from itertools import accumulate
while True:
    n, k = [int(x) for x in input().split()]
    if n == 0 and k == 0:
        break
    L = []
    for _ in range(n):
        L.append(int(input()))

    M = list(accumulate(L))
    S = []
    S.append(M[k-1])

    for i in range(k,n):
        S.append(M[i] - M[i-k])
    print(max(S))

Python: #!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile


def read(
    *shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def readi(*shape):
    return read(*shape)


def readi1(*shape):
    return [i - 1 for i in read(*shape)]


def readf(*shape):
    return read(*shape, f=float)


def reads(*shape):
    return read(*shape, f=str)


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[fill_value]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def main():
    n, k = readi(2)
    a = readi(n)
    tmp = sum(a[:k])
    ans = tmp
    for i in range(k, len(a)):
        tmp += a[i] - a[i - k]
        ans = max(ans, tmp)
    print(ans)


if __name__ == "__main__":
    main()