program main
  implicit none
  
  integer :: i,j,t,n,k,l(50)=0,s=0
  
  read(*,*)n,k
  read(*,*)(l(i),i=1,n)
  
  do i=1,N-1
     do j=i+1,N
        if(l(i) .gt. l(j))then
           t=l(i)
           l(i)=l(j)
           l(j)=t
        end if
     end do
  end do
  
  do i = n, n-k+1, -1
    s = s + l(i)
  end do
  
  write(*,*)s
end program main