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