l=list(map(int,open(0).read().split()));print((sum(sorted(l[2:])[:l[1]])))
a,b,*l=list(map(int,open(0).read().split()));print((sum(sorted(l)[:b])))
l = list(map(int, open(0).read().split()))
print((sum(sorted(l[2:])[: l[1]])))

a, b, *l = list(map(int, open(0).read().split()))
print((sum(sorted(l)[:b])))

-l = list(map(int, open(0).read().split())) -print((sum(sorted(l[2:])[: l[1]]))) +a, b, *l = list(map(int, open(0).read().split())) +print((sum(sorted(l)[:b])))