N, K = map(int, input().split(' '))
fruit_prices = list(map(int, input().split(' ')))
print("{0}個の果物から{1}種類選ぶ".format(N, K))
print(fruit_prices)

fruit_prices.sort()
print(fruit_prices)

min_price = 0

for i in range(K):
  min_price += fruit_prices[i]

print(min_price)