p00935 Decimal Sequences
Example

Input

3
3 0 1


Output

2
```python
j=''.join
u=input
n=int(u())
d=j(j(u().split())for i in[0]*(n//19+(n%19>0)))
i=0
while 1:
 if d.find(str(i))<0:
  print(i)
  exit() 
 i+=1
```