import Data.List

main = do
    let toInt = (read :: String -> Int)
    line1 <- getLine
    let ws = words line1
    let n = toInt $ ws !! 0
    let k = toInt $ ws !! 1
    line2 <- getLine
    let ps = take n $ map toInt $ words line2
    print $ sum $ take k $ sort ps
