readInt :: IO [Int]
readInt = map read . words <$> getLine

main :: IO ()
main = do
    [n, k] <- readInt
    p <- readInt
    print $ solve k p

solve :: Int -> [Int] -> Int
solve k p = sum . take k $ sort p
