import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {


    public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
int X=scan.nextInt();
        int N =scan.nextInt();


        int M[]=new int[N];
        int K=0;
        int Y=0;
        for(int i=0;i<N;i++) {M[i]=scan.nextInt();
        if (M[i]==X){K=1;
        Y=1;
        }}


      int P=X;
        int C=1;
            Arrays.sort(M);
        for(int i=0;i<N&&K==1&&C==1;i++){ C=0;
            K=0;
        for(int j=N-1;j>=0&&K==0;j--) {
            if (M[j] == X +i) {
             C= 1;
             P=M[j];
            }

            if (M[j] == X -i) {
                K = 1;
                P = M[j];
            }
        }

        }
        if (P>X&&Y==1&&C==0){System.out.println(2*X-P-1);}
        if (P>X&&Y==1&&C==1){System.out.println(2*X-P);}
        if (P<X&&Y==1&&K==0){System.out.println(P-1);}
        if (P<X&&Y==1&&K==1&&C==0){System.out.println(2*X-P);}
    
        if (P==X&&Y==1){System.out.println(P-1);}
        if (Y==0){System.out.println(X);}




    }
    }



 import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {


    public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
int X=scan.nextInt();
        int N =scan.nextInt();


        int M[]=new int[N];
        int K=0;
        int Y=0;
        for(int i=0;i<N;i++) {M[i]=scan.nextInt();
        if (M[i]==X){K=1;
        Y=1;
        }}


      int P=X;
        int C=1;
            Arrays.sort(M);
        for(int i=0;i<N&&K==1&&C==1;i++){ C=0;
            K=0;
        for(int j=N-1;j>=0&&K==0;j--) {
            if (M[j] == X +i) {
             C= 1;
             P=M[j];
            }

            if (M[j] == X -i) {
                K = 1;
                P = M[j];
            }
        }

        }
        if (P>X&&Y==1&&C==0){System.out.println(2*X-P-1);}
        if (P>X&&Y==1&&C==1){System.out.println(2*X-P);}
        if (P<X&&Y==1&&K==0){System.out.println(P-1);}
        if (P<X&&Y==1&&K==1&&C==0){System.out.println(2*X-P);}
    
        if (P==X&&Y==1){System.out.println(P-1);}
        if (Y==0){System.out.println(X);}




    }
    } Main public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
int X=scan.nextInt();
        int N =scan.nextInt();


        int M[]=new int[N];
        int K=0;
        int Y=0;
        for(int i=0;i<N;i++) {M[i]=scan.nextInt();
        if (M[i]==X){K=1;
        Y=1;
        }}


      int P=X;
        int C=1;
            Arrays.sort(M);
        for(int i=0;i<N&&K==1&&C==1;i++){ C=0;
            K=0;
        for(int j=N-1;j>=0&&K==0;j--) {
            if (M[j] == X +i) {
             C= 1;
             P=M[j];
            }

            if (M[j] == X -i) {
                K = 1;
                P = M[j];
            }
        }

        }
        if (P>X&&Y==1&&C==0){System.out.println(2*X-P-1);}
        if (P>X&&Y==1&&C==1){System.out.println(2*X-P);}
        if (P<X&&Y==1&&K==0){System.out.println(P-1);}
        if (P<X&&Y==1&&K==1&&C==0){System.out.println(2*X-P);}
    
        if (P==X&&Y==1){System.out.println(P-1);}
        if (Y==0){System.out.println(X);}




    } main {


        Scanner scan = new Scanner(System.in);
int X=scan.nextInt();
        int N =scan.nextInt();


        int M[]=new int[N];
        int K=0;
        int Y=0;
        for(int i=0;i<N;i++) {M[i]=scan.nextInt();
        if (M[i]==X){K=1;
        Y=1;
        }}


      int P=X;
        int C=1;
            Arrays.sort(M);
        for(int i=0;i<N&&K==1&&C==1;i++){ C=0;
            K=0;
        for(int j=N-1;j>=0&&K==0;j--) {
            if (M[j] == X +i) {
             C= 1;
             P=M[j];
            }

            if (M[j] == X -i) {
                K = 1;
                P = M[j];
            }
        }

        }
        if (P>X&&Y==1&&C==0){System.out.println(2*X-P-1);}
        if (P>X&&Y==1&&C==1){System.out.println(2*X-P);}
        if (P<X&&Y==1&&K==0){System.out.println(P-1);}
        if (P<X&&Y==1&&K==1&&C==0){System.out.println(2*X-P);}
    
        if (P==X&&Y==1){System.out.println(P-1);}
        if (Y==0){System.out.println(X);}




    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int X=scan.nextInt(); X scan.nextInt() scan.nextInt scan int N =scan.nextInt(); N scan.nextInt() scan.nextInt scan int M[]=new int[N]; M new int[N] N int K=0; K 0 int Y=0; Y 0 for(int i=0;i<N;i++) {M[i]=scan.nextInt();
        if (M[i]==X){K=1;
        Y=1;
        }} int i=0; int i=0; i 0 i<N i N i++ i++ i {M[i]=scan.nextInt();
        if (M[i]==X){K=1;
        Y=1;
        }} {M[i]=scan.nextInt();
        if (M[i]==X){K=1;
        Y=1;
        }} M[i]=scan.nextInt() M[i] M i scan.nextInt() scan.nextInt scan if (M[i]==X){K=1;
        Y=1;
        } M[i]==X M[i] M i X {K=1;
        Y=1;
        } K=1 K 1 Y=1 Y 1 int P=X; P X int C=1; C 1 Arrays.sort(M) Arrays.sort Arrays M for(int i=0;i<N&&K==1&&C==1;i++){ C=0;
            K=0;
        for(int j=N-1;j>=0&&K==0;j--) {
            if (M[j] == X +i) {
             C= 1;
             P=M[j];
            }

            if (M[j] == X -i) {
                K = 1;
                P = M[j];
            }
        }

        } int i=0; int i=0; i 0 i<N&&K==1&&C==1 i<N&&K==1&&C==1 i<N i N K==1 K 1 C==1 C 1 i++ i++ i { C=0;
            K=0;
        for(int j=N-1;j>=0&&K==0;j--) {
            if (M[j] == X +i) {
             C= 1;
             P=M[j];
            }

            if (M[j] == X -i) {
                K = 1;
                P = M[j];
            }
        }

        } { C=0;
            K=0;
        for(int j=N-1;j>=0&&K==0;j--) {
            if (M[j] == X +i) {
             C= 1;
             P=M[j];
            }

            if (M[j] == X -i) {
                K = 1;
                P = M[j];
            }
        }

        } C=0 C 0 K=0 K 0 for(int j=N-1;j>=0&&K==0;j--) {
            if (M[j] == X +i) {
             C= 1;
             P=M[j];
            }

            if (M[j] == X -i) {
                K = 1;
                P = M[j];
            }
        } int j=N-1; int j=N-1; j N-1 N 1 j>=0&&K==0 j>=0 j 0 K==0 K 0 j-- j-- j {
            if (M[j] == X +i) {
             C= 1;
             P=M[j];
            }

            if (M[j] == X -i) {
                K = 1;
                P = M[j];
            }
        } {
            if (M[j] == X +i) {
             C= 1;
             P=M[j];
            }

            if (M[j] == X -i) {
                K = 1;
                P = M[j];
            }
        } if (M[j] == X +i) {
             C= 1;
             P=M[j];
            } M[j] == X +i M[j] M j X +i X i {
             C= 1;
             P=M[j];
            } C= 1 C 1 P=M[j] P M[j] M j if (M[j] == X -i) {
                K = 1;
                P = M[j];
            } M[j] == X -i M[j] M j X -i X i {
                K = 1;
                P = M[j];
            } K = 1 K 1 P = M[j] P M[j] M j if (P>X&&Y==1&&C==0){System.out.println(2*X-P-1);} P>X&&Y==1&&C==0 P>X&&Y==1&&C==0 P>X P X Y==1 Y 1 C==0 C 0 {System.out.println(2*X-P-1);} System.out.println(2*X-P-1) System.out.println System.out System System.out 2*X-P-1 2*X-P-1 2*X 2 X P 1 if (P>X&&Y==1&&C==1){System.out.println(2*X-P);} P>X&&Y==1&&C==1 P>X&&Y==1&&C==1 P>X P X Y==1 Y 1 C==1 C 1 {System.out.println(2*X-P);} System.out.println(2*X-P) System.out.println System.out System System.out 2*X-P 2*X 2 X P if (P<X&&Y==1&&K==0){System.out.println(P-1);} P<X&&Y==1&&K==0 P<X&&Y==1&&K==0 P<X P X Y==1 Y 1 K==0 K 0 {System.out.println(P-1);} System.out.println(P-1) System.out.println System.out System System.out P-1 P 1 if (P<X&&Y==1&&K==1&&C==0){System.out.println(2*X-P);} P<X&&Y==1&&K==1&&C==0 K==1 P<X&&Y==1&&K==1&&C==0 P<X P X Y==1 Y 1 K==1 K 1 C==0 C 0 {System.out.println(2*X-P);} System.out.println(2*X-P) System.out.println System.out System System.out 2*X-P 2*X 2 X P if (P==X&&Y==1){System.out.println(P-1);} P==X&&Y==1 P==X P X Y==1 Y 1 {System.out.println(P-1);} System.out.println(P-1) System.out.println System.out System System.out P-1 P 1 if (Y==0){System.out.println(X);} Y==0 Y 0 {System.out.println(X);} System.out.println(X) System.out.println System.out System System.out X String[] args args public class Main {


    public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
int X=scan.nextInt();
        int N =scan.nextInt();


        int M[]=new int[N];
        int K=0;
        int Y=0;
        for(int i=0;i<N;i++) {M[i]=scan.nextInt();
        if (M[i]==X){K=1;
        Y=1;
        }}


      int P=X;
        int C=1;
            Arrays.sort(M);
        for(int i=0;i<N&&K==1&&C==1;i++){ C=0;
            K=0;
        for(int j=N-1;j>=0&&K==0;j--) {
            if (M[j] == X +i) {
             C= 1;
             P=M[j];
            }

            if (M[j] == X -i) {
                K = 1;
                P = M[j];
            }
        }

        }
        if (P>X&&Y==1&&C==0){System.out.println(2*X-P-1);}
        if (P>X&&Y==1&&C==1){System.out.println(2*X-P);}
        if (P<X&&Y==1&&K==0){System.out.println(P-1);}
        if (P<X&&Y==1&&K==1&&C==0){System.out.println(2*X-P);}
    
        if (P==X&&Y==1){System.out.println(P-1);}
        if (Y==0){System.out.println(X);}




    }
    } public class Main {


    public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
int X=scan.nextInt();
        int N =scan.nextInt();


        int M[]=new int[N];
        int K=0;
        int Y=0;
        for(int i=0;i<N;i++) {M[i]=scan.nextInt();
        if (M[i]==X){K=1;
        Y=1;
        }}


      int P=X;
        int C=1;
            Arrays.sort(M);
        for(int i=0;i<N&&K==1&&C==1;i++){ C=0;
            K=0;
        for(int j=N-1;j>=0&&K==0;j--) {
            if (M[j] == X +i) {
             C= 1;
             P=M[j];
            }

            if (M[j] == X -i) {
                K = 1;
                P = M[j];
            }
        }

        }
        if (P>X&&Y==1&&C==0){System.out.println(2*X-P-1);}
        if (P>X&&Y==1&&C==1){System.out.println(2*X-P);}
        if (P<X&&Y==1&&K==0){System.out.println(P-1);}
        if (P<X&&Y==1&&K==1&&C==0){System.out.println(2*X-P);}
    
        if (P==X&&Y==1){System.out.println(P-1);}
        if (Y==0){System.out.println(X);}




    }
    } Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {


    public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
int X=scan.nextInt();
        int N =scan.nextInt();


        int M[]=new int[N];
        int K=0;
        int Y=0;
        for(int i=0;i<N;i++) {M[i]=scan.nextInt();
        if (M[i]==X){K=1;
        Y=1;
        }}


      int P=X;
        int C=1;
            Arrays.sort(M);
        for(int i=0;i<N&&K==1&&C==1;i++){ C=0;
            K=0;
        for(int j=N-1;j>=0&&K==0;j--) {
            if (M[j] == X +i) {
             C= 1;
             P=M[j];
            }

            if (M[j] == X -i) {
                K = 1;
                P = M[j];
            }
        }

        }
        if (P>X&&Y==1&&C==0){System.out.println(2*X-P-1);}
        if (P>X&&Y==1&&C==1){System.out.println(2*X-P);}
        if (P<X&&Y==1&&K==0){System.out.println(P-1);}
        if (P<X&&Y==1&&K==1&&C==0){System.out.println(2*X-P);}
    
        if (P==X&&Y==1){System.out.println(P-1);}
        if (Y==0){System.out.println(X);}




    }
    }




