#include using ll = long long; using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int r = 0, p = 0; for (int i = 0; i < n; i++) { int a; cin >> a; r += a - p - 1; p = a; } cout << r << endl; return 0; }