
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE BangPatterns #-}

module Main where

import Debug.Trace
import Data.List
--import qualified Data.Set.Strict as Set
--import qualified Data.Map.Strict as Map

main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine
  ps <- map read . words <$> getLine
  --a `traceShow`
  print $ solve k ps

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