eolymp
bolt
Try our new interface for solving problems

Ants

Charles is fascinated by ants. In order to observe a colony of ants over a long period of time, Charles managed to build a program that uniquely identifies each ant using image recognition. (Yes, every ant is unique.) Inside the program, each ant is tagged with a unique nonnegative integer. Whenever there is a birth in the colony, the new ant is given a new tag that is different from all the tags already assigned. Whenever an ant disappears, its tag falls back into the pool of available tags. Charles’s program works as follows. It first scans the whole colony, building a list of the tags of the ants that are recognized. Then it assigns fresh tags to the new ants. To do so, the program simply picks the first natural number (i.e., nonnegative integer) that is not currently assigned to any ant, and so on. Due to some glitches in the image recognition device and in the program, there are sometimes negative or very large numbers that appear in the input list. These are simply ignored by Charles’s program. Your job is to reimplement the part of Charles’s program that finds a fresh tag to assign to a new ant. \InputFile The first line contains one integer $n~(0 \le n \le 10^6)$. The next $n$ lines contains integers $x_1, ..., x_n$, one per line. Each integer $x_i$ has less than $100$ digits. \OutputFile Print the smallest nonnegative integer that does not belong to the set $\{x_1, ..., x_n\}$.
Time limit 1 second
Memory limit 128 MiB
Input example #1
5
1
-1
0
3
10
Output example #1
2
Source 2019 ACM Southwestern Europe Regional Contest (SWERC), Paris, January 26 (2020), Problem C