406694: GYM102501 C Ants

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Antstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output
Charles is fascinated by ants. In order to observe a colony of ants over a long period, 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, different from all tags already assigned. Whenever some 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 the list of 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.

Input

The input consists of the following lines:

  • on the first line: an integer $$$N$$$;
  • on the next $$$N$$$ lines: some integers $$$X_1, \ldots , X_N$$$ , one per line.
Limits

The input satisfies $$$0 \le N \le 10^6$$$ . Each integer $$$X_i$$$ has less than 100 digits.

Output

The smallest natural number that does not belong to the set $$$\{X_1, \ldots , X_N\}$$$.

ExampleInput
5
1
-1
0
3
10
Output
2

加入题单

算法标签: