N = int(input()) A = [0] + list(map(int,input().split())) ans = 0 for i,v in enumerate(A): if i == 0: continue ans += v-(A[i-1])-1 print(ans)