from sys import stdin, stdout

read = stdin.readline

write = stdout.write

flush = stdout.flush

xr = range



def main():

	n,k = list(map(int,read().split()))

	a = list(map(int,read().split()))

	a.sort()

	write('{}\n'.format(sum(a[:k])))



if __name__ == "__main__":

	main()
from sys import stdin, stdout

read = stdin.readline

write = stdout.write

flush = stdout.flush

xr = range



def main():

	n,k = list(map(int,read().split()))

	a = sorted(list(map(int,read().split())))

	write('{}\n'.format(sum(a[:k])))



if __name__ == "__main__":

	main()
from sys import stdin, stdout

read = stdin.readline
write = stdout.write
flush = stdout.flush
xr = range


def main():
    n, k = list(map(int, read().split()))
    a = list(map(int, read().split()))
    a.sort()
    write("{}\n".format(sum(a[:k])))


if __name__ == "__main__":
    main()

from sys import stdin, stdout

read = stdin.readline
write = stdout.write
flush = stdout.flush
xr = range


def main():
    n, k = list(map(int, read().split()))
    a = sorted(list(map(int, read().split())))
    write("{}\n".format(sum(a[:k])))


if __name__ == "__main__":
    main()

-    a = list(map(int, read().split())) -    a.sort() +    a = sorted(list(map(int, read().split())))