import java.util.Scanner;
import java.math.*;

public class Main{
    public static void main(String[] args){
        Scanner sc =new Scanner(System.in);
        int x=sc.nextInt();
        int n=sc.nextInt();
        int count1=0;
        int count2=0;
        int plus=0;
        int minus=0;
        int flg=0;
        if(n==0){
            System.out.println(x);
        }else{
        int[] list = new int[n];
        for(int i=0; i<list.length; i++){
            list[i]=sc.nextInt();
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+plus){
                    plus++;
                }
            }
            count1++;
            if(count1>plus){
                break;
            }
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+minus){
                    minus--;
                }
            }
            count2--;
            if(count2<minus){
                break;
            }
        }
        flg=plus+minus;
        if(flg>=0){
            System.out.println(x+minus);
        }else if(flg<0){
            System.out.println(x+plus);
        }
    }
}
} import java.util.Scanner; Scanner java.util import java.math.*; math.* java public class Main{
    public static void main(String[] args){
        Scanner sc =new Scanner(System.in);
        int x=sc.nextInt();
        int n=sc.nextInt();
        int count1=0;
        int count2=0;
        int plus=0;
        int minus=0;
        int flg=0;
        if(n==0){
            System.out.println(x);
        }else{
        int[] list = new int[n];
        for(int i=0; i<list.length; i++){
            list[i]=sc.nextInt();
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+plus){
                    plus++;
                }
            }
            count1++;
            if(count1>plus){
                break;
            }
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+minus){
                    minus--;
                }
            }
            count2--;
            if(count2<minus){
                break;
            }
        }
        flg=plus+minus;
        if(flg>=0){
            System.out.println(x+minus);
        }else if(flg<0){
            System.out.println(x+plus);
        }
    }
}
} Main public static void main(String[] args){
        Scanner sc =new Scanner(System.in);
        int x=sc.nextInt();
        int n=sc.nextInt();
        int count1=0;
        int count2=0;
        int plus=0;
        int minus=0;
        int flg=0;
        if(n==0){
            System.out.println(x);
        }else{
        int[] list = new int[n];
        for(int i=0; i<list.length; i++){
            list[i]=sc.nextInt();
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+plus){
                    plus++;
                }
            }
            count1++;
            if(count1>plus){
                break;
            }
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+minus){
                    minus--;
                }
            }
            count2--;
            if(count2<minus){
                break;
            }
        }
        flg=plus+minus;
        if(flg>=0){
            System.out.println(x+minus);
        }else if(flg<0){
            System.out.println(x+plus);
        }
    }
} main {
        Scanner sc =new Scanner(System.in);
        int x=sc.nextInt();
        int n=sc.nextInt();
        int count1=0;
        int count2=0;
        int plus=0;
        int minus=0;
        int flg=0;
        if(n==0){
            System.out.println(x);
        }else{
        int[] list = new int[n];
        for(int i=0; i<list.length; i++){
            list[i]=sc.nextInt();
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+plus){
                    plus++;
                }
            }
            count1++;
            if(count1>plus){
                break;
            }
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+minus){
                    minus--;
                }
            }
            count2--;
            if(count2<minus){
                break;
            }
        }
        flg=plus+minus;
        if(flg>=0){
            System.out.println(x+minus);
        }else if(flg<0){
            System.out.println(x+plus);
        }
    }
} Scanner sc =new Scanner(System.in); sc new Scanner(System.in) int x=sc.nextInt(); x sc.nextInt() sc.nextInt sc int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int count1=0; count1 0 int count2=0; count2 0 int plus=0; plus 0 int minus=0; minus 0 int flg=0; flg 0 if(n==0){
            System.out.println(x);
        }else{
        int[] list = new int[n];
        for(int i=0; i<list.length; i++){
            list[i]=sc.nextInt();
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+plus){
                    plus++;
                }
            }
            count1++;
            if(count1>plus){
                break;
            }
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+minus){
                    minus--;
                }
            }
            count2--;
            if(count2<minus){
                break;
            }
        }
        flg=plus+minus;
        if(flg>=0){
            System.out.println(x+minus);
        }else if(flg<0){
            System.out.println(x+plus);
        }
    } n==0 n 0 {
            System.out.println(x);
        } System.out.println(x) System.out.println System.out System System.out x {
        int[] list = new int[n];
        for(int i=0; i<list.length; i++){
            list[i]=sc.nextInt();
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+plus){
                    plus++;
                }
            }
            count1++;
            if(count1>plus){
                break;
            }
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+minus){
                    minus--;
                }
            }
            count2--;
            if(count2<minus){
                break;
            }
        }
        flg=plus+minus;
        if(flg>=0){
            System.out.println(x+minus);
        }else if(flg<0){
            System.out.println(x+plus);
        }
    } int[] list = new int[n]; list new int[n] n for(int i=0; i<list.length; i++){
            list[i]=sc.nextInt();
        } int i=0; int i=0; i 0 i<list.length i list.length list list.length i++ i++ i {
            list[i]=sc.nextInt();
        } {
            list[i]=sc.nextInt();
        } list[i]=sc.nextInt() list[i] list i sc.nextInt() sc.nextInt sc while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+plus){
                    plus++;
                }
            }
            count1++;
            if(count1>plus){
                break;
            }
        } true {
            for(int i=0; i<list.length; i++){
                if(list[i]==x+plus){
                    plus++;
                }
            }
            count1++;
            if(count1>plus){
                break;
            }
        } for(int i=0; i<list.length; i++){
                if(list[i]==x+plus){
                    plus++;
                }
            } int i=0; int i=0; i 0 i<list.length i list.length list list.length i++ i++ i {
                if(list[i]==x+plus){
                    plus++;
                }
            } {
                if(list[i]==x+plus){
                    plus++;
                }
            } if(list[i]==x+plus){
                    plus++;
                } list[i]==x+plus list[i] list i x+plus x plus {
                    plus++;
                } plus++ plus count1++ count1 if(count1>plus){
                break;
            } count1>plus count1 plus {
                break;
            } break; while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+minus){
                    minus--;
                }
            }
            count2--;
            if(count2<minus){
                break;
            }
        } true {
            for(int i=0; i<list.length; i++){
                if(list[i]==x+minus){
                    minus--;
                }
            }
            count2--;
            if(count2<minus){
                break;
            }
        } for(int i=0; i<list.length; i++){
                if(list[i]==x+minus){
                    minus--;
                }
            } int i=0; int i=0; i 0 i<list.length i list.length list list.length i++ i++ i {
                if(list[i]==x+minus){
                    minus--;
                }
            } {
                if(list[i]==x+minus){
                    minus--;
                }
            } if(list[i]==x+minus){
                    minus--;
                } list[i]==x+minus list[i] list i x+minus x minus {
                    minus--;
                } minus-- minus count2-- count2 if(count2<minus){
                break;
            } count2<minus count2 minus {
                break;
            } break; flg=plus+minus flg plus+minus plus minus if(flg>=0){
            System.out.println(x+minus);
        }else if(flg<0){
            System.out.println(x+plus);
        } flg>=0 flg 0 {
            System.out.println(x+minus);
        } System.out.println(x+minus) System.out.println System.out System System.out x+minus x minus if(flg<0){
            System.out.println(x+plus);
        } flg<0 flg 0 {
            System.out.println(x+plus);
        } System.out.println(x+plus) System.out.println System.out System System.out x+plus x plus String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc =new Scanner(System.in);
        int x=sc.nextInt();
        int n=sc.nextInt();
        int count1=0;
        int count2=0;
        int plus=0;
        int minus=0;
        int flg=0;
        if(n==0){
            System.out.println(x);
        }else{
        int[] list = new int[n];
        for(int i=0; i<list.length; i++){
            list[i]=sc.nextInt();
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+plus){
                    plus++;
                }
            }
            count1++;
            if(count1>plus){
                break;
            }
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+minus){
                    minus--;
                }
            }
            count2--;
            if(count2<minus){
                break;
            }
        }
        flg=plus+minus;
        if(flg>=0){
            System.out.println(x+minus);
        }else if(flg<0){
            System.out.println(x+plus);
        }
    }
}
} public class Main{
    public static void main(String[] args){
        Scanner sc =new Scanner(System.in);
        int x=sc.nextInt();
        int n=sc.nextInt();
        int count1=0;
        int count2=0;
        int plus=0;
        int minus=0;
        int flg=0;
        if(n==0){
            System.out.println(x);
        }else{
        int[] list = new int[n];
        for(int i=0; i<list.length; i++){
            list[i]=sc.nextInt();
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+plus){
                    plus++;
                }
            }
            count1++;
            if(count1>plus){
                break;
            }
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+minus){
                    minus--;
                }
            }
            count2--;
            if(count2<minus){
                break;
            }
        }
        flg=plus+minus;
        if(flg>=0){
            System.out.println(x+minus);
        }else if(flg<0){
            System.out.println(x+plus);
        }
    }
}
} Main
import java.util.Scanner;
import java.math.*;

public class Main{
    public static void main(String[] args){
        Scanner sc =new Scanner(System.in);
        int x=sc.nextInt();
        int n=sc.nextInt();
        int count1=0;
        int count2=0;
        int plus=0;
        int minus=0;
        int flg=0;
        if(n==0){
            System.out.println(x);
        }else{
        int[] list = new int[n];
        for(int i=0; i<list.length; i++){
            list[i]=sc.nextInt();
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+plus){
                    plus++;
                }
            }
            count1++;
            if(count1>plus){
                break;
            }
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+minus){
                    minus--;
                }
            }
            count2--;
            if(count2<minus){
                break;
            }
        }
        flg=plus+minus;
        if(flg>=0){
            System.out.println(x+minus);
        }else if(flg<0){
            System.out.println(x+plus);
        }
    }
}
}