Problem: You went to the store, selling types of chocolates. There are chocolates of type in stock.
You have unlimited amount of cash (so you are not restricted by any prices) and want to buy as many chocolates as possible. However if you buy chocolates of type (clearly, ), then for all at least one of the following must hold:
- (you bought zero chocolates of type )
- (you bought less chocolates of type than of type )
For example, the array satisfies the requirement above (assuming that all ), while arrays , and don't.
Calculate the maximum number of chocolates you can buy.
Input Format: The first line contains an integer (), denoting the number of types of chocolate.
The next line contains integers (), denoting the number of chocolates of each type.
Output Format: Print the maximum number of chocolates you can buy.
Note: In the first example, it is optimal to buy: chocolates.
In the second example, it is optimal to buy: chocolates.
In the third example, it is optimal to buy: chocolates.