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

print(ans)