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 <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vec> vec2;
typedef map<ll,ll> MPll;
typedef set<ll> setl;

const ll INF = 1ll << 60;
const ld EPS = 1e-10;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

//for文
#define FOR(i,a,b) for(ll i = (ll)a;i < (ll)b;i++)
#define FORE(i,a,b) for(ll i = (ll) a;i <= (ll) b;i++ )
#define REP(i,size)  for(ll i =(ll)0;i<size;i++)
#define REPE(i,size)  for(ll i =(ll)0;i<=size;i++)
#define REPR(i,size)  for(ll i =(ll)size;i>=0;i--)
#define FOREACH(it, vec) for (auto it = vec.begin(); it != vec.end(); it++)

//ソート
#define ALL(vec) (vec).begin(),(vec).end()
#define SORT(vec) sort(ALL(vec))
#define SORTA(arr) sort(arr,arr + (sizeof(arr) / sizeof(ll)))
#define INVSORT(vec) sort((vec).rbegin(),(vec).rend())
#define REV(vec) reverse(ALL(vec))
#define REVA(arr) reverse(arr,arr + (sizeof(arr) / sizeof(ll)))
#define INVSORTA(arr) sort(arr,arr + (sizeof(arr) / sizeof(ll))),REVA(arr)

//最大値最小値
#define MAX(vec) *max_element(ALL(vec))
#define UNIQ(vec) SORT(vec);vec.erase(unique(ALL(vec)),vec.end())
#define MIN(vec) *min_element(ALL(vec))

//出力
#define printl(a) cout << a << "\n"
#define print(a) cout << a
#define OUT(a) printf("%lld\n",a)
#define OUTA(array) REP(i,sizeof(array)/sizeof(ll)) printf("%lld\n",array[i])
#define OUTV(vec) REP(i,vec.size()) printf("%lld\n",vec[i])
#define SP printf(" ")

//入力
#define IN(x) scanf("%lld",&x)
#define INV(vec) REP(i,vec.size()) scanf("%lld",&vec[i])
#define INA(array) REP(i,sizeof(array)/sizeof(ll)) scanf("%lld",array + i)
#define INS(x) cin >> x

//型
#define P pair
#define vp vector<P>
#define F first
#define S second

//その他
#define PB push_back
#define MP make_pair
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,-1,sizeof(a))
#define INFI(a) memset(a,INF,sizeof(a))
#define MEM(a,b) memset(a,(b),sizeof(a))

//関数
template<class T> inline void amax(T &a,const T &b) { if(a < b) a = b; }
template<class T> inline void amin(T &a,const T &b) { if(a > b) a = b; }
/*
struct structure{
    ll num1,num2,string s;
    bool operator<(const rest &another) const{
        return this->s < another.s;
    }
    structure(ll a,ll b,string s){
        this->num1 = a,this->num2=b,this->s=s;
    }
};a
*/
//特殊
//#define int ll
#define _CRT_SECURE_NO_WARNINGS

#define DEBUG

#ifdef DEBUG
#define debug(x) cerr << #x << ":" << x<<"\n"
#define  debugV(V) REP(i,V.size()){cerr << i << ":" << V[i]<<endl;}
#define  debugA(A) REP(i,sizeof(A)/sizeof(ll)){cerr << i << ":" << V[i]<<endl;}
#else
#define debug(x)
#define debugV(x)
#define debugA(x)
#endif




signed main(){
    ll n,k;
    cin >> n;
    cin >> k;
    vec A(n+1,0);
    ll a;
    for(ll i= 1;i<n+1;i++){
        cin >> a;
        A[i] = A[i-1] +  a;
    };

    ll max = 0;
    ll temp;
    for (int j = k; j < n+1; ++j) {
        temp = A[j] - A[j-k];
        amax(max,temp);
    }

    cout << max;


}

C++: #include<iostream>
using namespace std;
int map[100001][1001];
int list[100001];
int k,Max;
int rec(int now, int c){
//	cout<<"    list["<<now<<"]"<<list[now]<<" c:"<<c<<endl;
	if(k==c)return list[now];

	return rec(now-1,c+1)+list[now];
}
int main(){
	int n;
	while(cin>>n>>k&&(n||k)){
		Max=-10000000;
		for(int i=0;i<n;i++){
//			cout<<"["<<i<<"]";
			cin>>list[i];
//			cout<<list[i]<<endl;
			if(i>=k-1){
				int tmp=0;
				tmp=rec(i,1);
//				cout<<"    ----------"<<endl;
				if(tmp>Max)Max=tmp;
			}

		}
		cout<<Max<<endl;
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <functional> //sort(A,A.end(),greater<int>());???????????????
#include <queue>
#include <stack>
#include <vector>

#define INF 10 << 10

int a[100001];

int main() {
	int n, k;
	while (cin >> n >> k && n != 0 && k != 0) {
		memset(a, 0, sizeof(a));
		for (int i = 1; i <= n; ++i) {
			cin >> a[i];
			a[i] += a[i - 1];
		}
		int ans = 0;
		for (int i = 0; i < n - k; ++i) {
			ans = max(ans, a[i + k] - a[i]);
		}
		cout << ans << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#define INF 90000000000
using namespace std;

int ary[100010];
int main(){
	int N,K;
	long long cnt,ccnt;
	while(1){
		cin>>N>>K;
		if(N==0&&K==0) break;
		for(int i=1;i<=N;i++){
			cin>>ary[i];
		}
		ccnt=0;
		for(int j=1;j<=K;j++){
			ccnt+=ary[j];
		}
		cnt=ccnt;
		for(int i=2;i+(K-1)<=N;i++){
			ccnt+=ary[i+(K-1)];
			ccnt-=ary[i-1];
			cnt=max(cnt,ccnt);
		}
		cout<<cnt<<endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
using namespace std;
#define MAX_N 10000

unsigned long long int n, k, i, j, a[MAX_N], max = 0, f;

int sort(const void *a, const void *b){
  return *(int*)b - *(int*)a;
}

int main(){
  while(1){
    scanf("%lld %lld", &n, &k);
    if(n == 0 && k == 0) break;
    max = 0;
    for(i = 0; i < n; i++) scanf("%lld", &a[i]);
    for(i = 0; i < n - k; i++){
      f = 0;
      for(j = 0; j < k; j++) f += a[i + j];
      if(f > max) max = f;
    }
    printf("%lld\n", max);
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N,K;
    while(cin >> N >> K,N|K){
        vector<int> a(N);
        rep(i,N)cin >> a[i];
        int left=0,right=0;
        ll sum= 0,res=0;
        for(left=0;;left++){
            while(right<N&&right-left<K){
                sum+=a[right];
                right++;
            }
            res = max(res,sum);
            sum-=a[left];
            if(right==N&&left==N-K)break;
        }
        cout << res << endl;
    }
    return 0;
}