def main():
	N = int(input())
	K = int(input())

	list = []

	for i in range(N):
		list.append(int(input()))
	
	list.sort()

	part = list[0:K]

	print(sum(part))

if __name__ == '__main__':
    main()