from sys import stdin, stdout
read = stdin.readline
write = stdout.write
flush = stdout.flush
xr = range

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

if __name__ == "__main__":
	main()