Limak is a grizzly bear who desires power and adoration. He wants to win on upcoming elections and rule over the Bearland.
There isNCandidates, including Limak. We know how many citizens is going to vote for each candidate. NowI-th candidate would get ai Votes. Limak is candidate number1. To win in elections, he must get strictly more votes than any other candidate.
Victory is more important than everything else so Limak decided to cheat. He'll steal votes from the He opponents by bribing some citizens. To bribe a citizen, Limak must give him or her one candy-citizens is bears and bears like candies. Limak doesn ' t have many candies and wonders-how many citizens does he has to bribe?
Input
The first line contains a single integer n (2?≤? N? ≤?100)-Number of candidates.
The second line containsNspace-separated integers a1,? a 2,?...,? a N (1?≤? a i? ≤?1000)-Number of votes for each candidate. Limak is candidate number1.
Note that after bribing number of votes for some candidate might is zero or might be greater than .
Output
Print the minimum number of citizens Limak must bribe to has strictly more votes than any other candidate.
Sample Test (s) input
55 1 11) 2 8
Output
4
Input
41 8 8 8
Output
6
Input
27 6
Output
0
Note
In the first sample Limak have5Votes. One of the ways to achieve victory are to bribe4Citizens want to vote for the third candidate. Then numbers of votes would be9,?1,?7,?2,?8(Limak would has9Votes). Alternatively, Limak could steal only3Votes from the third candidate and1Vote from the second candidate to get situation9,?0,?8,?2,?8.
In the second sample Limak would steal 2 votes from each candidate. Situation'll be 7,?6,?6,?6.
In the third sample Limak are a winner without bribing any citizen.
At that time,--= thought it would time out
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Codeforces Round #318 [Russiancodecup Thanks-round] (Div. 2) A. Bear and Elections (priority queue)