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)