eolymp
bolt
Try our new interface for solving problems

MEX

Do you know how hard it is to pull the trigger? The famous dictator Lee Xi Seung has an army of $10^5$ at his disposal. He numbered them from $0$ to $10^5 - 1$. The lower the number a person has, the higher his commanding abilities. Then he repressed $n$ of them. Now the dictator is going to conduct a small victorious war with a neighboring state. Therefore, he urgently needs to choose the most talented military who is alive. \InputFile The first line contains the number of repressed $n\:(1 \le n < 10^5)$. The second line contains their numbers in Lee Xi Seung's list --- all numbers less than $10^5$. \OutputFile Print one number --- the number of the most talented alive military.
Time limit 1 second
Memory limit 128 MiB
Input example #1
8
3 0 1 7 2 4 6 17
Output example #1
5
Author Олег Петров
Source Летняя школа Севастополь 2013, Волна 1, День 3