import sys input = sys.stdin.readline N=int(input()) A=list(map(int, input().split())) ans = max(A) - N print(ans)