// -*- coding:utf-8-unix -*-

use proconio::input;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn main() {
    input! {
        n: u16,
        k: u16,
        mut p: [u16; n],
    }

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