//use std::convert::TryInto;
#![allow(dead_code)]

fn main(){
    let nk: Vec<i32> = input_vec();
    let k = nk[1];
    let mut p: Vec<i32> = input_vec();
    // input end

    let mut ans = 0;
    p.sort();
    for i in 0..k {
        ans += p[i as usize];
    }
    println!("{}", ans);
}


/*
 * input function
 */
fn input<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
