import Control.Monad
import Data.Maybe
import Data.List
import qualified Data.ByteString.Char8 as BS

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

main :: IO ()
main = do
    [n, k] <- getIntList
    prices <- getIntList

    let total = sum $ take k $ sort prices 

    print total