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