import java.util.ArrayList;
import java.util.Scanner;
import java.util.TreeSet;
/**
* @Author 陈平安
* @Date 2022/8/29 9:25
* @PackageName:PACKAGE_NAME
* @ClassName: Main
* @Description: TODO
* @Version 1.0
*/
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
//获取数据
int sum = 0;///每组的和
TreeSet map = new TreeSet();//利用其具有自动排序的功能
ArrayList<Integer> list = new ArrayList<>();//储存待测数据
for (int j = 0; j < n; j++) {
list.add(scanner.nextInt());
}//for循环获取数据
//System.out.println(list.toString());
for (int j = 0; j < list.size() - m+1; j++) {//遍历数据元素,记得要加一,因为临界条件的值也有用处
//******************************+1************************
//System.out.println(j+" j");
for (int k = j; k < j + m; k++) {
sum += list.get(k);
}
map.add(sum);
// sum = 0;
sum = 0;//每m组循环以后记得置为空
}
System.out.println(map.first());//第一个元素就是最小值
}
}