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

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

int main(){
	int n,k,max,pre,buf,*his;
	
	while(1){
		cin >> n >> k;
		
		if(n || k){
			max = pre = buf = 0;
			his = new int[k-1];
					
			for(int i = 0; i < k-1; i++){
				cin >> buf;
				pre += buf;
				his[i] = buf;
			}
			
			for(int i = k-1; i < n; i++){
				cin >> buf;
				pre += buf;
				
				if(max < pre){
					max = pre;
				}
				
				pre -= his[0];
				for(int i = 0; i < k-1; i++){
					his[i] = his[i+1];
				}
				his[k-2] = buf;
			}
			
			cout << max << endl;
		}else{
			break;
		}
	}
	
	return 0;
}

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,pre=0;
		vector<int> seq(n);
		for(int i=0; i<n; ++i){
			cin >> seq[i];
		}
		for(int i=0; i<k; ++i){
			maxi+=seq[i];
			pre+=seq[i];
		}
		for(int i=1; i<n-k+1; ++i){
			pre=pre-seq[i-1]+seq[i+k-1];
			maxi=max(maxi,pre);
		}
		cout << maxi << endl;
	}
	return 0;
}

C++: #include<stdio.h>

int re[10001];

int main(){
	int n,k,i,j,c;
	re[0]=0;
	while(0<=scanf("%d%d",&n,&k)){
		if(n==0 && k==0)break;
		
		for(i=1;i<=n;i++){
			scanf("%d",&c);
			re[i]=re[i-1]+c;
		}
		c=re[k];
		for(i=1;i+k-1<=n;i++){
			if(c<re[i+k-1]-re[i-1])c=re[i+k-1]-re[i-1];
		}
		printf("%d\n",c);
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int n,k,box[10000]={0},sum=0,summ;
int main(){
    while(1){
        cin >> n >> k;
    if(n==0&&k==0)break;
        int ans=0;
        for(int i=0;i<k;i++){
            cin >> box[i];
            sum+=box[i];
            }
          for(int i=k;i<n;i++){
                cin >> box[i];
                sum+=box[i]-box[i-k];
                if(sum>ans)ans=sum;
        }
    cout << ans <<endl;

    }
    return 0;
}

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

int main()
{
int n,k,d,S ;
while(1){ 
cin >> n >> k ;
if(n==0&&k==0){
break;
}
vector<int> a(n) ;
for(int i=0;i<n;i++){
cin >> d ;
a.at(i)=d ;
}
S=0 ;
for(int j=0;j<k;j++){
S=S+a.at(j) ;
}
int A=0;
A=S ;
for(int l=0;l<n-k;l++){
S=S-a.at(l)+a.at(l+k);
A=max(A,S) ;
}
cout << A << endl;
}
}

C++: #include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n, k;
    
    while(true)
    {
        scanf("%d", &n);
        scanf("%d", &k);
        
        if(n == 0 && k == 0) { break; }
        
        vector<int> a(n);
    
        for(int i = 0; i < n; i++)
        {
            scanf("%d", &a[i]);
        }
        
        int sum = 0;
        
        for(int i = 0; i < k; i++)
        {
            sum += a[i];
        }
        
        int ret = sum;
        
        for(int i = k; i < n; i++)
        {
            sum += (a[i] - a[i - k]);
            
            ret = max(ret, sum);
        }
        
        printf("%d\n", ret);
    }
    
    return 0;
}

C++: #include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem0516 : Maximum Sum **/
int main()
{
	int N, K; cin>>N>>K;
	vector<int> a(N);
	rep(i, N) cin>>a[i];
	
	int k=0;
	rep(i, K) k+=a[i];
	
	int ans=k;
	REP(i, K, N) {
		k+=a[i]; k-=a[i-K];
		ans = max(ans, k);
	}
	cout << ans << endl;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>

#define rep(i, a, b) for(int i = (a); (i) < (b); i++)

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> num;
	int tmp;
	rep(i, 0, n) {
		cin >> tmp;
		num.push_back(tmp);
	}

	int s = 0;
	rep(i, 1, n-k+1) {
		tmp = 0;
		rep(j, 0, k) {
			tmp += num[i+j-1];
		}

		if(s < tmp) s = tmp;
	}

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

C++: #include<cstdio>

int main()
{
    int n,m,a[100008];
    while(~scanf("%d%d",&n,&m))
    {
        if(!n&&!m) break;
        for(int i=0;i<n;i++) scanf("%d",&a[i]);
        for(int i=0;i<m;i++) temp += a[i];
        int sum = 0,cap = 0;
        for(int i=0;i<n;i++){
            if(cap!=m){ sum += a[i]; cap++; }
            else sum += a[i]-a[i-3];
            if(sum>temp) temp=sum;
        }
        printf("%d\n",temp);
    }
    return 0;
}

C++: #include<bits/stdc++.h>

using namespace std ;

int main()
{
	int n ;
	while( cin >> n ,n )
	{
		int m ;
		cin >> m ;
		int num[ n + 1 ] ;
		num[ 0 ] = 0 ;
		for( int i = 1 ; i <= n ; i++ )
		{
			cin >> num[ i ] ;
			num[ i ] += num[ i - 1 ] ;
		}
		int ans = 0 ;
		for( int i = m ; i <= n ; i++ )
			ans = max( ans ,num[ i ] - num[ i - m ] ) ;
		cout << ans << endl ;
	}
	return 0 ;
}

C++: #include <iostream>
using namespace std;
int main()
{
	while(1)
	{
		int n,k; cin >> n >> k ;
		if(n==0 && k==0) break;
		int* a=new int[n]; int sum=0; int max=0;
		for(int i=0;i<n;i++) cin >> a[i] ;
		for(int i=0;i<k;i++) sum+=a[i];
		max=sum;
		for(int i=k;i<n;i++)
		{
			sum=sum+a[i]-a[i-k];
			if(sum>max) max=sum;
		}
		cout << max << '\n';
	}
}

C++: #include <fstream>
#include <cstdint>
#include <algorithm>
#include <cstring>

std::int64_t a[100000];

int main() {
	std::ifstream ifs("input.txt");
	std::ofstream ofs("output.txt");
	
	int n, k;
	while (ifs >> n >> k, n + k != 0) {
		for (int i = 0; i < n; ++i)
			ifs >> a[i];

		std::int64_t res = 0, mem = 0;
		for (int i = 0; i < n; ++i) {
			mem += a[i];

			if (i >= k)
				mem -= a[i - k];

			res = std::max(res, mem);
		}

		ofs << res << std::endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MAX_N 100000

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int n, k, a[MAX_N+1];

int main(){
  while(scanf("%d%d", &n, &k) && n+k){
    REP(i, 1, n+1) scanf("%d", a+i);
    REP(i, 1, n+1) a[i] += a[i-1];
    int res = 0;
    REP(i, k, n+1) res = max(res, a[i] - a[i-k]);
    printf("%d\n", res);
  }
  return 0;
}