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