import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer(br.readLine());
int n=Integer.parseInt(st.nextToken());
int k=Integer.parseInt(st.nextToken());
st=new StringTokenizer(br.readLine());
int[] nums=new int[n];
for(int i=0;i<n;i++)nums[i]=Integer.parseInt(st.nextToken());
int l=0;
int r=0;
int cnt=1;
int sum=nums[0];
int ans=Integer.MIN_VALUE;
while(l<=r){
if(r==n)break;
if(cnt<=k){
if(cnt==k)ans=Math.max(ans,sum);
cnt++;
++r;
if(r<n)sum+=nums[r];
}
else{
cnt--;
sum-=nums[l++];
}
}
System.out.println(ans);
}
}
#투포인터