N = int(input()) print(max(map(int, input().split())) - N)