N = int(input())
K=int(input())
p=[]
for i in range(0, N): 
	ele = int(input()) 
    p.append(ele) 

x=0
final_list=[]
for i in range(0,K):
	min1 = 9999999; 
    
	for j in range(len(p)):       
  		if p[j]<min1: 
    		min1 = p[j]; 
	p.remove(min1); 
	final_list.append(min1) 
           

for ele in range(0, len(final_list)): 
	x = x + final_list[ele] 
  
print(x) 
