#K76752. Taco: Stolen Fruits

    ID: 34712 Type: Default 1000ms 256MiB

Taco: Stolen Fruits

Taco: Stolen Fruits

You are given n fruits, each with an associated integer value, and an integer k representing the number of fruits that were stolen. Your task is to compute the minimum and maximum total value of the stolen fruits.

The minimum total value is obtained by choosing the k fruits with the smallest values, and the maximum total value is obtained by choosing the k fruits with the largest values.

You can express these sums mathematically as:

$$\text{min\_sum} = \sum_{i=1}^{k} a_i \quad \text{and} \quad \text{max\_sum} = \sum_{i=n-k+1}^{n} a_i, $$

where \(a_i\) denotes the fruit values sorted in non-decreasing order.

Implement a program that reads the input from standard input and prints the results to standard output.

inputFormat

The first line contains two integers n and k, where 1 ≤ k ≤ n, representing the total number of fruits and the number of stolen fruits, respectively.

The second line contains n space-separated integers, where each integer represents the value of a fruit.

outputFormat

Output two integers separated by a space: the minimum possible sum and the maximum possible sum of the values of the k stolen fruits.

## sample
5 2
3 7 2 5 8
5 15