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