import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List

main = do
  li <- BS.getLine
  let [n,k] = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  li <- BS.getLine
  let ps = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  let ans = compute n k ps
  print ans

compute :: Int -> Int -> [Int] -> Int
compute n k ps = sum $ take k $ sort ps