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>
#include<cstring>
using namespace std;
int main(){
  int n,k,a,max;
  int set[100001];
  while(1){
  cin >> n >> k;
  if(n==0 && k==0)break;
  max=0;
  for(int i=0;i<n;i++){
    scanf("%d",&set[i]);
  }

  for(int i=0,sum=0;i<n-k;i++,sum=0){
    for(int j=i;j<i+k;j++){
      sum += set[j];
    }
    if(max<sum || i==1){
      max=sum;
    }
  }
  printf("%d\n",max);
  }
}

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

int k, m, n, h, w;
ll t[1 << 17], d[1 << 17];

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

C++: #define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<algorithm>
#define rep(i,a) for(int i=0;i<(a);++i)

int n, k;
int a[100001], sum[100001];

int main(){
	while (scanf("%d%d", &n, &k), n|k){
		rep(i, 100001)sum[i] = 0;
		scanf("%d", &a[0]);
		for (int i = 1; i < n; ++i){
			scanf("%d", &a[i]);
			sum[i] = sum[i - 1] + a[i];
		}
		int ans = 0;
		for (int i = 0; i < n - k; ++i){
			ans = std::max(ans, sum[i + k] - sum[i]);
		}
		printf("%d\n", ans);
	}
	return 0;
}

C++: #include<stdio.h>

#include<algorithm>


using namespace std ;



int main()
{
	int n ,k ;

	while( 1 )
	{
		scanf( "%d %d" ,&n ,&k ) ;


		if( !( n | k ) )
		{
			return 0 ;
		}


		int if_k = k - 1 ;

		int ans = -10001 ,other[ 100000 ] ;
		
		int sum = 0 ;

		int i ;
		for( i = 0 ; i < n ; ++i )
		{
			scanf( "%d" ,&other[ i ] ) ;

			sum += other[ i ] ;


			if( i > if_k )
			{
				sum -= other[ i - k ] ;
			}

			if( i >= if_k )
			{
				ans = max( ans ,sum ) ;
			}
		}


		printf( "%d\n" ,ans ) ;
	}
}

C++: // tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
inline void modAdd(int& _a, int _b, int _m) { _a = (_a + _b) % _m; }
inline void modAdd(lint& _a, lint _b, lint _m) { _a = (_a + _b) % _m; }
inline void minUpdate(int& _a, int _b) { _a = min(_a, _b); }
inline void minUpdate(lint& _a, lint _b) { _a = min(_a, _b); }
inline void maxUpdate(int& _a, int _b) { _a = max(_a, _b); }
inline void maxUpdate(lint& _a, lint _b) { _a = max(_a, _b); }

int n, k, a[100010];

void solve() {
	for_(i,1,n) a[i] = a[i] +  a[i - 1];
	int ans = a[k - 1];
	for_(i,k,n) maxUpdate(ans, a[i] - a[i - k]);
	printf("%d\n", ans);;
}

int main() {
	while (cin >> n >> k, n) {
		for_(i,0,n) scanf("%d", &a[i]);
		solve();
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;

static const double eps = 1e-8;

int stage[16][16];
int bit[100001];

int sumBIT(int i,int* bit){
	int s = 0;
	while(i > 0){
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void addBIT(int i, int x,int* bit,int n){
	while(i <= n){
		bit[i] += x;
		i += i & -i;
	}	
}


int main(){
	int n,k;
	while(~scanf("%d %d",&n,&k)){
		if(n==k && k==0) break;
		memset(bit,0,sizeof(bit));
		for(int i=0;i<n;i++){
			int num;
			scanf("%d",&num);
			addBIT(i+1,num,bit,100000);
		}

		int res = numeric_limits<int>::min();
		for(int i=1;i+2<=n;i++){
			res = max(sumBIT(i+2,bit) - sumBIT(i-1,bit),res);
		}

		printf("%d\n",res);
	}
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
//#define int long long
using namespace std;

int n, k;
int a[100000];

signed main()
{
	while (true) {
		cin >> n >> k;
		if (n == 0 && k == 0) break;
		rep(i,n) cin >> a[i];

		int mx;
		int sum = 0;
		rep(i,k) {
			sum += a[i];
		}
		mx = sum;
		//cout << "first = " << mx << endl;

		for (int i=0; i<=n-k -1; i++) {
			sum -= a[i];
			sum += a[i+k];
			//printf("i = %d, sum = %d\n", i, sum);
			mx = max(mx, sum);
		}

		cout << mx << endl;
	}
}

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

int main(){

  int n, k;
  while( cin >> n >> k, n+k ) {
    int max_sum, sum, data[100000];
    
    cin >> data[0] >> data[1] >> data[2];
    max_sum = sum = data[0] + data[1] + data[2];
    
    for(int i=k; i<n; i++) {
      cin >> data[i];
      sum -= data[i-k];
      sum += data[i];
      max_sum = max(max_sum, sum);
    }

    cout << max_sum << 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,maxi=0;
	cin >> n >> k;
	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 <set>
#include <algorithm>
//#include <fstream>

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.maximumsum", "r", stdin );
	int n,k;

	while (1) {
		cin >> n >> k;

		if (n == 0 && k == 0 ){
			break;
		} // end if
		vector <int> a (n, 0 );
//		vector <int> sum (n - k + 1, 0 );
 		set <int, greater<int> > sum;

		for (int i = 0; i < n; ++i){
			cin >> a[i];
		} // end for
		
		for (int i = 0; i < n - k + 1; ++i){
			int s = 0;
			for (int j = i; j < i + k; ++j){
				s += a[j];
			} // end for
			sum.insert (s);
		} // end for

		set <int, greater<int> >::iterator it = sum.begin();

		cout << (*it) << endl;
	} // end loop
		
	return 0;
}