B - Mix Juice 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MB

配点 : 200

問題文

ある店で N 種類の果物、果物 1, \ldots, N が売られており、それぞれの価格は一個あたり p_1, \ldots, p_N 円です。

この店で K 種類の果物を一個ずつ買うとき、それらの合計価格として考えられる最小の金額を求めてください。

制約

  • 1 \leq K \leq N \leq 1000
  • 1 \leq p_i \leq 1000
  • 入力中の値はすべて整数である。

入力

入力は以下の形式で標準入力から与えられる。

N K
p_1 p_2 \ldots p_N

出力

果物の最小の合計価格を表す整数を出力せよ。


入力例 1

5 3
50 100 80 120 80

出力例 1

210

この店では、果物 1, 2, 3, 4, 5 がそれぞれ 50 円、100 円、80 円、120 円、80 円で売られています。

これらから 3 種類を買うときの最小合計価格は、果物 1, 3, 5 を買うときの 50 + 80 + 80 = 210 円です。


入力例 2

1 1
1000

出力例 2

1000

Score : 200 points

Problem Statement

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

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

Constraints

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

Input

Input is given from Standard Input in the following format:

N K
p_1 p_2 \ldots p_N

Output

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


Sample Input 1

5 3
50 100 80 120 80

Sample Output 1

210

This shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.

The minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.


Sample Input 2

1 1
1000

Sample Output 2

1000