#include #include #include #include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); uint32_t N, i; cin >> N; vector A(N); for (i = 0; i != N; ++i) cin >> A[i]; uint64_t ans = A[0] - 1; for (i = 1; i != N; ++i) ans += A[i] - A[i - 1] - 1; cout << ans << '\n'; return 0; }