Go: package main

import "fmt"

func main() {

	for true {
		var n, k int
		fmt.Scan(&n, &k)

		if n == 0 && k == 0 {
			return
		}
		
		a := make([]int, n)
		ans := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Scan(&a[i])
			if i == 0 {
				ans[i] = a[i]
			} else {
				ans[i] = ans[i-1] + a[i]
			}
		}
		max := 0
		for i := k; i < n; i++ {
			t := ans[i] - ans[i-k]
			if max < t {
				max = t
			}
		}
		fmt.Println(max)
	}
}

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)

Python: def main():
	while True:
		a = []
		n, k = [int(x) for x in input().split()]
		if n == 0 and k == 0: break
		for i in range(n): a.append(int(input()))
		l = [0]
		for i in range(1, n - k + 1): l.append(a[i + k - 1] - a[i - 1])
		maxsum = 0
		maxi = 0
		s = 0
		for i, x in enumerate(l):
			s += x
			if s >= maxsum:
				maxsum = s
				maxi = i
		print(sum(a[i - 1:i + k - 1]))
main()

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: def resolve():
    N, M = [int(i) for i in input().split()]
    while N + M != 0:
        A = [int(input()) for _ in range(N)]
        preSum = [0] * (N + 1)
        for i in range(N):
            preSum[i + 1] = preSum[i] + A[i]
        maxA = -10000 * M - 1
        for i in range(M, N):
            maxA = max(maxA, preSum[i] - preSum[i - M])
        print(maxA)
        N, M = [int(i) for i in input().split()]


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()))
        count = 0
    for i in range(k):
        count += a[i]
        ans = count
    for i in range(k, n):
        count += a[i]
        count -= a[i - k]
        ans = max(ans, count)
    print(ans)

Python: while 1:
    n,k = [int(i) for i in input().split()]
    if not (n and k):
        break
    a = [int(input()) for i in range(n)]
    b = [0]*len(a)

    for i in range(n):
        b[i] = b[i-1] + a[i]
    b = b + [0]

    c = [b[i + k - 1] - b[i - 1] for i in range(n - k + 1)]

    print(max(c))

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 = [0] * n
    s[0] = sum(a[0:k])
    for i in range(1, n-k+1):
        s[i] = s[i-1] - a[i-1] + a[k+i-1]
    print(max(s))

Python: if __name__ == '__main__':
    [n, k] = [int(i) for i in input().split()]
    a = []
    for i in range(n):
        a.append(int(input()))

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

    for i in range(1, n-k+1):
        new = old - a[i-1] + a[i+k-1]
        if new > max:
            max = new
        old = new

    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=[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 main():
	while True:
		a = []
		n, k = [int(x) for x in input().split()]
		if n == 0 and k == 0: break
		for i in range(n): a.append(int(input()))
		l = [0]
		for i in range(1, n - k + 1): l.append(a[i + k - 1] - a[i - 1])
		maxsum = 0
		maxi = 0
		s = 0
		for i, x in enumerate(l):
			s += x
			if s >= maxsum:
				maxsum = s
				maxi = i
		print(sum(a[maxi:maxi + k]))
main()

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()))

    list1 = []
    try:
        for i in range(n):
            num = 0
            for j in range(k):
                num += a[i + j]
            list1.append(num)
    except:
        pass

    print(max(list1))

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

    a = [0]*n
    for i in range(n):
        a[i] = int(input())

    s = [0]*(n+1)
    for i in range(n):
        s[i+1] = s[i] + a[i]
    
    ans = -float('inf')
    for i in range(n-k+1):
        ans = max(ans,s[k+i]-s[i])
    print(ans)

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