Imports System

Module Program
    Sub Main(args As String())

        Dim tmp As String() = Split(Console.ReadLine())
        Dim N As Integer = CInt(tmp(0))
        Dim K As Integer = CInt(tmp(1))
        Dim tmp2 As String() = Split(Console.ReadLine())
        Dim p As New List(Of Integer)

        For i As Integer = 0 To N - 1
            p.Add(CInt(tmp2(i)))
        Next

        p.Sort()

        Dim sum As Integer = 0
        For i As Integer = 0 To K - 1
            sum += p(i)
        Next

        Console.WriteLine(sum)

    End Sub
End Module
