def main():

    entrada = list(map(int, input().split()))

    frutas = list(map(int, input().split()))

    frutas.sort()

    suma = 0

    for i in range(entrada[1]):

        suma = suma + frutas[i]



    print(suma)





if __name__ == "__main__":

    main()

N, K = input().split(" ")



price = input().split(" ")

list1 = []



for j in price:

    list1.append(int(j))



list1 = list1[:int(N)]

list1.sort()



list2 = list1[:int(K)]



summ = 0

for i in list2[:int(K)]:

    summ += int(i)



print(summ)

def main():
    entrada = list(map(int, input().split()))
    frutas = list(map(int, input().split()))
    frutas.sort()
    suma = 0
    for i in range(entrada[1]):
        suma = suma + frutas[i]
    print(suma)


if __name__ == "__main__":
    main()

N, K = input().split(" ")
price = input().split(" ")
list1 = []
for j in price:
    list1.append(int(j))
list1 = list1[: int(N)]
list1.sort()
list2 = list1[: int(K)]
summ = 0
for i in list2[: int(K)]:
    summ += int(i)
print(summ)

-def main(): -    entrada = list(map(int, input().split())) -    frutas = list(map(int, input().split())) -    frutas.sort() -    suma = 0 -    for i in range(entrada[1]): -        suma = suma + frutas[i] -    print(suma) - - -if __name__ == "__main__": -    main() +N, K = input().split(" ") +price = input().split(" ") +list1 = [] +for j in price: +    list1.append(int(j)) +list1 = list1[: int(N)] +list1.sort() +list2 = list1[: int(K)] +summ = 0 +for i in list2[: int(K)]: +    summ += int(i) +print(summ)