n = int(input()) A = [0]+list(map(int,input().split())) ans = 0 for a,na in zip(A,A[1:]): ans += na-a-1 print(ans)