extern crate itertools;

use itertools::Itertools;
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let k:usize = read();
    let arr:Vec<usize> = (0..n).map(|_| read()).collect();
    let it = arr.iter().combinations(k);
    let mut ans = std::usize::MAX;
    for i in it {
        let mut tmp = 0;
        for j in i {
            tmp += j;
        }
        ans = min(ans, tmp);
    }
    println!("{}", ans);
}
