program mixjuice

 implicit none
 integer::n,k,temp,i,j,ans
 integer,allocatable::p(:)

 read*,n,k
 allocate(p(n))
 read*,p
! print*,p

!sort

 do i=1,n-1
  do j=1,n-i
   if(p(i)>=p(j+i)) then
    temp=p(j+i)
    p(j+i)=p(i)
    p(i)=temp
   end if
  end do
 end do
!print*,p

ans=0
 do i=1,k
  ans=ans+p(i)
 end do

print*,ans

end program mixjuice
    
