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>
using namespace std;

int data[100000]={0};

int main(){
    int n,k;
    int sum = -1;
    int tmp,tmp2,tmp3,tmp4;
    while(1){
        cin >> n >> k;
        if(n == 0 && k == 0) break;
        for(int i=0;i<n;i++) cin >> data[i];
        for(int i=0;i<=((n-k)/4)+1;i++){
            tmp = 0;
            tmp2 = 0;
            tmp3 = 0;
            tmp4 = 0;
            for(int j=i,g=n-(i+1),f=(n/2)+i,r=(n/2)+i;j<i+k;j++,g--,f++,r--){
                tmp += data[j];
                tmp2 += data[g];
                tmp3 += data[f];
                tmp4 += data[r];
            }
            if(sum < tmp) sum = tmp;
            else if(sum < tmp2) sum = tmp2;
            else if(sum < tmp3) sum = tmp3;
            else if(sum < tmp4) sum = tmp4;
        }
        cout << sum << endl;
    }
}

C++: #include <cstdio>

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

C++: #include<stdio.h>


int main(){
	
	int n,m;
	int input[100000];
	int cont;
	int now;
	int max;
	int i;
	while(1){
		
		scanf("%d%d",&n,&m);
		if(n==0 && m ==0){
			break;
		}
		
		for(i=0;i<n;i++){
			scanf("%d",&input[i]);
		}
		
		now = 0;
		
		for(i=0;i<m;i++){
			now += input[i];
		}
		max=now;
		
		cont = m;
		
		for(i=m;i<n;i++){
			now-=input[i-m];
			now+=input[i];
			
			if(now>max){
				max=now;
			}
		}
		
		printf("%d\n",max);
	}
	
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, k;
ll a[100100];
ll sum[100100];

int main(){
	while (cin >> n >> k&&n + k){
		fill(a, a + 100100, 0);
		fill(sum, sum + 100100, 0);
		ll MAX = -1000000000;
		REP(i, n)cin >> a[i];
		sum[0] = a[0];
		REP(i, n){
			sum[i + 1] = sum[i] + a[i];
		}
		REP(i, n - k + 1){
			sum[i + k] -= sum[i];
		}
		FOR(i, k, n){
			MAX = max(MAX, sum[i]);
		}
		cout << MAX << endl;
	}
}

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;
    bool flag = true;
    while(flag) {
        cin >> n;
        cin >> k;
        if(n == 0 and k == 0){
            return 0;
        }
        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+1; j < n + 1; ++j) {
            temp = A[j] - A[j - k];
            amax(max, temp);
        }

        cout << max;
    }

}