import           Data.Maybe (fromJust)
import           Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as BSC8
import           Data.List (sort)


readInts :: IO [Int]
readInts = map ( fst . fromJust . BSC8.readInt ) . BSC8.words <$> BSC8.getLine

main :: IO ()
main = do
  (_:k:_) <- readInts
  ps <- readInts
  print $ sum . take k . sort $ ps
