N = int(input())
n_vote = []

for i in range(N):
    n_vote.append(int(input()))
    
cand = n_vote[1:len(n_vote)]
dasom = n_vote[0]
    
if(N == 1):
    print(0)

else:
    num = 0
    cand = sorted(cand, reverse = True)
    while(cand[0] >= dasom):
        dasom += 1
        cand[0] -= 1
        num += 1
        cand = sorted(cand, reverse = True)

    print(num)

'프로그래밍 > 알고리즘' 카테고리의 다른 글

[Python] 백준 1475번 : 방 번호  (0) 2020.04.13
[Python] 백준 2309번 : 일곱난쟁이  (0) 2020.02.18
[Python] 백준 2217번 : 로프  (0) 2020.02.18

+ Recent posts