import java.util.*;
public class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int n = sc.nextInt();//n个数
int m = sc.nextInt();//求m个连续的数的最大和
int number[] = new int[n];
for (int i = 0; i < n; i++) {
number[i] = sc.nextInt();
}
List<Integer> list = new ArrayList<>();
int numb [] = new int[number.length+m];//形成一个环
//拷贝数组
System.arraycopy(number, 0, numb, 0, number.length);
for (int i = 0; i < m; i++) {
numb[(number.length+i)] = number[i];
}
for (int i = 0; i < numb.length; i++) {
if((i+m)<=numb.length){
int num = 0;
for (int j = i; j < m+i; j++) {
num = num + numb[j];
}
list.add(num);
}
}
Object[] objects = list.toArray();
Arrays.sort(objects);
System.out.print((int)objects[objects.length-1]);
}
}