Crossing Out Numbers
InterviewTime limit1sMemory limit128 MB
Cross out as few numbers as possible so the numbers left behind read 1 to k in order.
Problem
Jasio wrote down a sequence of integers. We call a sequence a good sequence if it consists of the consecutive natural numbers starting from .
Jasio wants to cross out some of the numbers so that the ones that remain form a good sequence. The numbers that are left keep their original order (that is, they form a subsequence of the original sequence). Help him cross out as few numbers as possible.
If no good sequence can be formed in any way, then all of the numbers must be crossed out.
Input
The first line contains a single integer (), the length of the sequence.
The second line contains the integers (), separated by spaces.
Output
Print a single line containing the minimum number of numbers Jasio must cross out.