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

C++: #include<iostream>
#include<cstdio>

using namespace std;

int main(void)
{
	int n, k, s, b;
	int a[10001], m[10001];
	while (1)
	{
		cin >> n >> k;
		if (n == 0 && k == 0)
			break;
		for (int i = 0;i < n;i++)
			cin >> a[i];

		m[0] = a[0];
		for (int i = 0;i < n;i++)
			m[i + 1] = m[i] + a[i];

		s = m[k] - m[0];
		for (int i = 0;i < n - k + 1;i++)
		{
			b = m[i + k + 1] - m[i + 1];
			if (s < b) 
				s = b;

		}

	}
	cout << s << endl;
	return 0;
}

C++: #include<iostream>
using namespace std;

int num[100000];
int main(){
    int n, k;
    int a;
    int i;
    long long int now;
    long long int max;
    cin >> n >> k;
    while(n || k){
        for(i=0;i<n-k;i++){
            num[i] = 0;
        }
        now = 0;
        max = 0;
        for(i=0;i<k;i++){
            cin >> a;
            num[i] -= a;
            now += a;
        }
        for(;i<n-k;i++){
            cin >> a;
            num[i] -= a;
            num[i-k] += a;
        }
        for(;i<n;i++){
            cin >> a;
            num[i-k] += a;
        }
        for(i=0;i<n-k+1;i++){
            if(max < now){
                max = now;
            }
            now += num[i];
        }
        cout << max << endl;
        cin >> n >> k;
    }
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int num[1000000];
int main()
{
	int n, k, ans = 0, sans=0;
	while (1)
	{
		scanf("%d%d", &n, &k);
		if (n == 0 && k == 0)
			break;
		for (int i = 0; i < n; i++)
		{
			scanf("%d", &num[i]);
		}
		for (int i = 0; i < n - k; i++)
		{
			for (int j = i; j < i + k; j++)
			{
				sans += num[j];
			}
			if (ans < sans)
				ans = sans;
			sans = 0;
		}
		printf("%d\n", ans);
	}
	return 0;
}

C++: #include<iostream>
#include<string.h>
using namespace std;
int main(){
	int i,i2,n,k,a[5001],max=-100000000,sum;
	cin>>n>>k;
	while(n!=0){
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n-k+1;i++){
		sum=0;
		for(i2=i;i2<i+k;i2++)sum+=a[i2];
		if(sum>max){
			max=sum;
		}
	}
	cout<<max<<endl;
	cin>>n>>k;
	}
}

C++: #include <iostream>
#include <vector>
using namespace std;

int main(){
  int numn,lisn,num;
  vector<int> outp;
  int outn = 1;
  for(int l = 0;;l++){
    cin >> numn >> lisn;
    if(numn == 0 && lisn == 0){
      break;
    }
    outp.resize(l+1,0);
    vector<int> lists(numn,0);
    for(int n = 0;n<numn;n++){
      cin >> lists[n];
    }
    for(int k = 0;k<numn-lisn+1;k++){
      outn = 0;
      for(int c = 0;c<lisn;c++){
        outn += lists[c+k];
      }
      if(outp[l] < outn){
        outp[l] = outn;
      }
    }
  }
  for(int q = 0;q<outp.size();q++){
    cout << outp[q] << endl;
  }
}

C++: #include<iostream>
#include<cstdio>

using namespace std;

int main(void)
{
int n,k,s,b;
while(1)
{
cin >> n >>k;
if(n==0 && k==0)
break;
int m[100001]={0};
int a[100001];

for(int i=0;i<n;i++)
cin >> a[i];

m[0]=0;
for(int i=0;i<n;i++)
m[i+1]=m[i]+a[i];

s=0;

for(int i=1;i+k<=n;i++)
{
b=m[i+k]-m[i];
if(s<b)
s=b;
}
cout << s << endl;
}
return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define ini 0
using namespace std;

int rlay[100001];

int main (){

while (1){

memset(rlay ,0 ,sizeof(rlay));
int n,k,input,ansmax=0;
cin>>n>>k;
if (n==0 && k==0)break;

rlay[0]=ini;
for (int i=1;i<=n;i++){
        cin>>input;
        rlay[i]=input+rlay[i-1];
}

for (int i=n;i-k>0;i--){
        ansmax = max ( rlay[i]-rlay[i-k] ,ansmax );
}

cout<<ansmax<<endl;
}

return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;



int main(){
        int n, k;
        vector<double> v;
        cin >> n>>k;

        int num=0;
        for(int i=0; i<n; i++) {  //ベクターに格納
                cin>>num; //入力をnumに代入
                v.push_back(num); //ベクターvにプッシュ
        }


        int max=0;
        int temp=0;
        for(int i=0; (i+k)<=n; i++) {
                for(int j=0; j<k; j++) {
                        temp+=v[i+j]; //tempにvのiからi+k番目までの総和を代入
                }
                //cout<<temp<<endl;
                if(temp>max) max=temp;  //tempが最も大きい数値ならmaxを更新
                temp=0; //tempの初帰化
        }
        cout<<max<<endl;
}

C++: #include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <cstdlib>
#include <algorithm>
using namespace std;
/*
int dfs(int w,int h,int noww,int nowh,int n,int b){
	++n;
	if(noww>w || nowh>h) return 0;
	if(noww==w && nowh==h) return 1;
	int ret=0;
	n=0;
	if(n)
	ret+=dfs(w,h,++noww,nowh,n,b);
	ret+=dfs(w,h,noww,++nowh,n,b);
	ret+=dfs(w,h,++noww,nowh,n,b);
	ret+=dfs(w,h,noww,++nowh,n,b);
	return ret;
}

int main()u{
	int w,h;
	cin >> w >> h;
	cout << dfs(w,h,1,1,2,0) << endl;
	return 0;
}
*/

int main(){
	int n,k;
	while(cin >> n >> k&&n!=0&&k!=0){
		int maxi=0;
		vector<int> seq(n);
		for(int i=0; i<n; ++i){
			cin >> seq[i];
		}
		for(int i=0; i<n-k+1; ++i){
			int sum=0;
			for(int j=i;j<i+k;++j){
				sum+=seq[j];
			}
			maxi=max(sum,maxi);
		}
		cout << maxi << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <algorithm>
using namespace std;

typedef long long ll;

int a[1000000];

int main()
{
    int n, k;
    while(cin >> n >> k && n && k) {
        for(int i = 0; i < n; i++) {
            cin >> a[i];
        }
        
        ll pre = 0;
        for(int i = 0; i < k; i++) {
            pre += a[i];
        }
        
        ll ret = pre;
        for(int i = 0; i < n - k; i++) {
            pre = pre - a[i] + a[k + i];
            ret = max(ret, pre);
        }
        
        cout << ret << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
  bool flag=true;
  int n,k;
  cin>>n>>k;
  while(flag){
    vector<long long> a(n+1);
    a[0]=0;
    for(int i=0;i<n;i++){
      long long x;
      cin>>x;
      a[i+1]=a[i]+x;
    }
    long long ans=0;
    for(int i=0;i<=n-k;i++){
      ans=max(ans,a[k+i]-a[i]);
    }
    cout<<ans<<endl;
    cin>>n>>k;
    if(n==0&&k==0) flag=false;
  }
}

C++: #include <algorithm>
#include <cstdio>
#include <climits>
#include <vector>
using namespace std;

int main() {
    while(true) {
        int n,k; scanf("%d%d", &n, &k);
        if(n==0) break;
        static int a[100001];
        a[0] = 0;
        for(int i = 0; i < n; i++) {
            int x; scanf("%d", &x);
            a[i+1] = a[i] + x;
        }
        int max_sum = INT_MIN;
        for(int i = k; i <= n; i++) {
            max_sum = max(max_sum, a[i]-a[i-k]);
        }
        printf("%d\n", max_sum);
    }
    return 0;
}