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