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:
    a,b=map(int,input().split())
    if a==0 and b==0: break

    line=[]
    kei=[]
    i=0
    
    for _ in range(a):line.append(int(input()))
    
    for j in range(0,b):i += line[j]
    
    for I in range(b,a):
        i += line[I]-line[I-b]
        kei.append(i)
        
    print(max(kei))

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

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

    s = [0 for i in range(n+1)]
    # 累積和配列の生成
    for i in range(n):
        s[i+1] = s[i] + a[i]

    ans = -float("inf")
    for i in range(n-k):
        ans = max(ans, s[i+k] - s[i])

    print(ans)

Python: # coding: utf-8
# Your code here!

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: def solve(n,k,a):
    S=[0]*(n+1)
    S[0]=a[0]
    for i in range(0,n):
        S[i+1]=S[i]+a[i]
    ans=-S[k-1]
    for i in range(0,n-k+1):
        if ans<S[i+k]-S[i]:
            ans=S[i+k]-S[i]
    return ans
n,k=map(int,input().split())
while n>0:
    a=[int(input()) for _ in range(n)]
    ans=solve(n,k,a)
    print(ans) 
    n,k=map(int,input().split())

Python: import sys
def mips():
    return map(int,input().split())
def ii():
    return int(input())
#AOJ_maximum sum
def procedure():
    N,K = mips()
    if N == 0:
        sys.exit(0)
    A = []
    res = -(10**100)
    for _ in range(N):
        a = ii()
        A.append(a)
    S = [0]
    for i in range(N):
        s = S[i] + A[i]
        S.append(s)
    for i in range(N-K):
        res = max(res,S[i+K]-S[i])
    print(res)
while True:
    procedure()

Python: from queue import deque

while True:
    n, k = map(int, input().split())
    if not n:
        break
    q = deque(int(input()) for _ in range(k))
    ans = sum(q)
    for _ in range(n - k):
        new = int(input())
        q.append(new)
        old = q.popleft()
        if new > old:
            ans += new - old
    print(ans)

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: # coding: utf-8
# Your code here!
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])
    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 = [int(i) for i in 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: while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    else:
        x=[]
        x=[int(input()) for i in range(n)]
        l=len(x)
        b=[]
        if l<k:
            pass
        else:
            s=sum(x[0:k])
            b.append(s)
            for j in range(n-k):
                s=s-x[j]+x[j+k]
                b.append(s)
        m=max(b)
        print(m)

Python: import itertools
while True:
    N, K = map(int, input().split())
    if N==K==0:
        break
    S = [int(input()) for _ in range(N)]
    
    Scum = [0] + list(itertools.accumulate(S))
    reg = -10**9
    for i in range(N-K+1):
        partial_sum = Scum[i+K] - Scum[i]
        reg = max(reg, partial_sum)
    print(reg)

Python: for i in range(5):
    n,k = map(int,input().split())
    if n == 0 and k == 0:
        break
    else:
        ruiseki = [0]*(n+1)
        total = 0
        maximum = -(10**9+7)
        for i in range(n):
            p = int(input())
            total += p
            ruiseki[i+1] = total
        for i in range(n-k+1):
            if ruiseki[i+k]-ruiseki[i]>maximum:
                maximum = ruiseki[i+k]-ruiseki[i]
        print(maximum)

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: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0516

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def main(args):
    while True:
        n, k = map(int, input().split())
        if n == 0 and k == 0:
            break

        d = deque([int(input()) for _ in range(k)])
        sum_value = sum(d)
        maximum_sum = sum_value

        for _ in range(n-k):
            v = int(input())
            o = d.popleft()
            if sum_value - o + v > maximum_sum:
                maximum_sum = sum_value - o + v
            d.append(v)

        print(maximum_sum)


if __name__ == '__main__':
    main(sys.argv[1:])

Python: n,k = map(int,input().split())
a = [int(input()) for i in range(n)]

unko = [0]
for i in range(n):
        unko.append(unko[i]+a[i])
Inf = float("inf")*(-1)
mvl = Inf
for i in range(n-k+1):
        if unko[i+k]-unko[i] >= mvl:
                mvl = unko[i+k]-unko[i]
print(mvl)

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

Python: a=[]

while True:
    n,k=map(int,input().split())
    
    if n==0 and k==0:
        break
    
    maxa=0
    suma=0
    
    for i in range(n):
        a.append(int(input()))
        if i<k:
            suma +=a[i]
        else:
            suma +=a[i]-a[i-k]
        if i>k-1 and maxa<suma:
            maxa=suma
            
    print(maxa)

Python: while True:
    n,k = map(int,input().split())
    if n == k == 0:
        break
    N_lis = []
    for i in range(n):
        N_lis.append(int(input()))
    N_max = 0
    N_sum_1 = 0
    N_sum_2 = 0
    for j in range(k):
        N_sum_1 += N_lis[j]
    for l in range(n - k):
        N_sum_2 = N_sum_1 - N_lis[l] + N_lis[l + k]
        if N_sum_2 > N_max:
            N_max = N_sum_2
        N_sum_1 = N_sum_2
    print(N_max)

Python: while True:
    n,k = map(int,input().split())
    if n == 0 and k == 0:
        break
    a = [int(input()) for i in range(n)]
    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)