n,k = map(int,input().split)
 
s = input().rstrip().split(' ')
st = []
 
for i in range(0,n):
  a = int(s[i]) 
  st.append(a)

new_st = sorted(st)
sum = 0
for j in range(0,k):
  sum += new_st[j]
  
print(sum)
    