#include #include #include #include using namespace std; int main() { int n; cin >> n; vector a(n); for (int &v : a) cin >> v; a.push_back(0); sort(a.begin(), a.end()); long long int ans = 0; for (int i = a.size() - 1; i > 0; i--) { ans += a[i] - a[i - 1] - 1; } cout << ans << '\n'; }