100 atcoder#ABC171B. [ABC171B] Mix Juice

[ABC171B] Mix Juice

Score : 200200 points

Problem Statement

A shop sells NN kinds of fruits, Fruit 1,,N1, \ldots, N, at prices of p1,,pNp_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)

Here, we will choose KK kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.

Constraints

  • 1KN10001 \leq K \leq N \leq 1000
  • 1pi10001 \leq p_i \leq 1000
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK

p1p_1 p2p_2 \ldots pNp_N

Output

Print an integer representing the minimum possible total price of fruits.

5 3
50 100 80 120 80
210

This shop sells Fruit 11, 22, 33, 44, and 55 for 5050 yen, 100100 yen, 8080 yen, 120120 yen, and 8080 yen, respectively.

The minimum total price for three kinds of fruits is 50+80+80=21050 + 80 + 80 = 210 yen when choosing Fruit 11, 33, and 55.

1 1
1000
1000