import java.util.*;
public class Main{
public static void main(String[] args){
setTest();
}
public static void setTest(){
Set<Integer> set=new HashSet<>();
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int i=0;
while(sc.hasNext())
set.add(sc.nextInt());
for(i=0;i<n;i++)
{
if(set.contains((i)))
continue;
else
break;
}
System.out.println(i);
}
}
public class Main{
public static void main(String[] args){
setTest();
}
public static void setTest(){
Set<Integer> set=new HashSet<>();
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int i=0;
while(sc.hasNext())
set.add(sc.nextInt());
for(i=0;i<n;i++)
{
if(set.contains((i)))
continue;
else
break;
}
System.out.println(i);
}
}