nn=int(input())
kk=int(input())
num_value = list(map(int, input().split())) 
num_value.sort()
goukei=0
for i in range(kk):
    for k in range(nn-i):
        if num_value[i]>num_value[k]:
            num_value[i],num_value[k]=num_value[k],num_value[i]
goukei=goukei+num_value[i]
print(goukei)

