INTEGER :: N, K, i, j, ans
INTEGER, ALLOCATABLE :: p(:)
READ*, N, K
ALLOCATE( p(N) )
READ*, p
DO i = 1, n
	DO j = 2, n
		IF(p(j) .lt. p(j-1)) THEN
			ans = p(j)
			p(j) = p(j-1)
			p(j-1) = ans
		END IF
	END DO
END DO
ans = 0
DO i = 1, K
	ans = ans + p(i)
END DO
PRINT*, ans
END