
Module Module1

    Sub main()
        Dim user1 = Split(Console.ReadLine(), " ")
        Dim user2 = Console.ReadLine().Split(" ")
        Dim typeF As Long = user1(0)
        Dim buyNum As Long = user1(1)
        Dim fruits As Long()
        Dim total As Long = 0

        fruits = Array.ConvertAll(user2, Function(i As String) CLng(i))
        Array.Sort(fruits)

        For i = 0 To buyNum - 1
            total = total + fruits(i)
        Next

        Console.WriteLine(total)
    End Sub
end module