import java.util.Scanner;
public class Minimum_Money_Needed {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int weight = sc.nextInt();
int price[] = new int[weight];
for (int i = 0; i < price.length; i++) {
price[i] = sc.nextInt();
}
System.out.println(Min_Money(price, 0, weight));
}
public static int Min_Money(int[] prices, int i, int weight) {
if (weight == 0) {
return 0;
}
if(i == prices.length) {
return 0;
}
int inc = 0;
if (weight >= i+1) {
inc = Min_Money(prices, i, weight - (i+1))+ prices[i];
}
int exc = Min_Money(prices, i + 1, weight);
return Math.min(inc, exc);
}
}