N = int(input()) A = list(map(int, input().split())) A = [0]+A print(sum(A[i+1]-A[i]-1 for i in range(N)))