local function reada(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read"*n"end end return unpack(r)end 
N=io.read"*n"
K=io.read"*n"
p=reada(N)
table.sort(p)
s=0
for i=1,K do
s=s+p[i]
end
print(s)