Update appNew update is available. Click here to update.

Football Game

Last Updated: 29 Sep, 2020
Difficulty: Easy

PROBLEM STATEMENT

Try Problem

Monk's favorite game is Football and his favorite club is "Manchester United". Manchester United has qualified for the Champions League Final which is to be held at the Wembley Stadium in London. So, he decided to go there and watch his favorite team play. After reaching the stadium, he saw that many people have lined up for the match tickets. He knows that there are 'M' rows in the stadium with different seating capacities. They may or may not be equal. The price of the ticket depends on the row. If the row has 'K' vacant seats, then the price of the ticket will be 'K' pounds. Now, every football fan standing in the line will get a ticket one by one.

You are given 'N' number of fans waiting for the tickets and seating capacities of different rows. The club wants to gain maximum pounds with the help of ticket sales.

Your task is to print the maximum possible pounds that the club will gain with the help of ticket sales.

Input Format:
The first line of input contains two integers 'M', and 'N', where 'M' denotes the number of rows and 'N' denotes the number of fans waiting in the line to get a ticket.

The second line contains 'M' single space-separated integers where 'VACANT_SEATS[i]' denotes the number of seats initially empty in the ith row.
Output Format:
For each output, print a single integer denoting the maximum pounds the club will earn.
Note:
You do not need to print anything, it has already been taken care of. Just implement the given function.
Constraints:
1 <= 'M' <= 5 * 10^5 
1 <= 'N' <= 10^9 
1 <= 'VACANT_SEATS[i]' <=10^9 

Time Limit: 1 sec