#C2022. Calculate Total Bonus

    ID: 45293 Type: Default 1000ms 256MiB

Calculate Total Bonus

Calculate Total Bonus

You are given two integers \(K\) and \(M\) along with a list of \(M\) bonus amounts. Your task is to calculate the total bonus awarded to the top \(K\) employees based on their bonus amounts.

First, sort the bonus amounts in descending order. Then, sum the top \(K\) values to obtain the total bonus. In mathematical terms, if the sorted bonuses are \(b_1, b_2, \dots, b_M\) where \(b_1 \ge b_2 \ge \cdots \ge b_M\), the answer is:

[ \text{Total Bonus} = \sum_{i=1}^{K} b_i ]

Make sure to read input from standard input and output the result to standard output.

inputFormat

The input is given via standard input in the following format:

K M
bonus_1 bonus_2 ... bonus_M

Where:

  • K is the number of top employees to consider.
  • M is the total number of bonus amounts provided.
  • bonus_1, bonus_2, ..., bonus_M are the bonus amounts (integers).

outputFormat

The output should be a single integer representing the total bonus awarded to the top \(K\) employees, printed to standard output.

## sample
3 5
3000 5000 2000 4000 1000
12000