Consecutive integers - MarisaOJ: Marisa Online Judge

Consecutive integers

Time limit: 1000 ms
Memory limit: 256 MB
You are given an array $A$ of $n$ integers. Find the minimum number of numbers you need to replace to make $A$ consist of only consecutive integers. ### Input - The first line contains an integer $n$. - The second line contains $n$ integers $A_i$. ### Output - Print the minimum number of integers you have to replace. ### Constraints - $1 \le n \le 10^5$. - $1 \le A_i \le 10^9$. ### Example Input: ``` 3 4 10 5 ``` Output: ``` 1 ``` Note: Replace $10$ with $6$.