Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Minimum Excluded

By TarifEzaz · Limits 1s, 512 MB

In a given set of integers, the “mex” or the minimum excluded value is the smallest non-negative integer that is not present in the set. For example, the mex of the set {0,1,2,4} is 3.

In this problem, you will be given a set of numbers, you will have to print the minimum excluded value of that set.

Input

The first line of input contains an integer N, the size of the set.

The next N inputs will have one non-negative integer each, the elements of the set. Each element will appear at most once in the set.

For 10 points, N will be less than or equal to 100 and the elements will be less than or equal to 1000.

For 20 points, N will be less than or equal to 100000 and the elements will be less than or equal to 105.

For 70 points, N will be less than or equal to 100000 and the elements will be less than or equal to 109.

Output

Output one input, the mex value of the given set.

Sample

InputOutput
4
0 1 2 4
3

    Discussion

    Statistics


    60% Solution Ratio

    BRACU_1isPrimeEarliest, 6M ago

    ProjectDFastest, 0.0s

    ProjectDLightest, 131 kB

    Jarif_RahmanShortest, 229B

    Submit

    Login to submit