import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd n = int(input()) a = list(map(int,input().split())) ans = 0 for i in range(n-1): ans += a[i+1] - a[i] - 1 ans += a[0]-1 print(ans)