{-# LANGUAGE TypeApplications #-}

import           Control.Monad
import           Control.Applicative
import           Data.List
import           Data.Char
import           Control.Arrow

main = do
  [n, k] <- map (read @Int) . words <$> getLine
  print =<< sum . take k . sort . map (read @Int) . words <$> getLine

