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

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



sum = 0

min_index = 0



for i in range(k):

    min_index = price_list.index(min(price_list))

    sum += price_list.pop(min_index)



print(sum)
n, k = list(map(int, input().split()))

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



price_list.sort()

sum = 0



for i in range(k):

    sum += price_list[i]



print(sum)
n, k = list(map(int, input().split()))
price_list = list(map(int, input().split()))
sum = 0
min_index = 0
for i in range(k):
    min_index = price_list.index(min(price_list))
    sum += price_list.pop(min_index)
print(sum)

n, k = list(map(int, input().split()))
price_list = list(map(int, input().split()))
price_list.sort()
sum = 0
for i in range(k):
    sum += price_list[i]
print(sum)

+price_list.sort() -min_index = 0 -    min_index = price_list.index(min(price_list)) -    sum += price_list.pop(min_index) +    sum += price_list[i]