import java.util.Scanner;
import java.util.Arrays;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int n = sc.nextInt();
        int[] p = new int[n];
        for(int i = 0; i<n; i++){
            p[i] = sc.nextInt();
        }

        Arrays.sort(p);
        int ans = -100000000;
        int ansLow, ansHigh;
        int count = 0;
        int matchNotAns = -1000000000;

        for(int j = 0; j<1000; j++){
            for(int k = 0; k<n; k++){
                if(x - j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
                else if(x + j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
            }
            if(count == 1 && j!=0){
                if(matchNotAns == x - j){
                    ans = x + j;
                }
                else if(matchNotAns == x + j){
                    ans = x - j;
                }
                break;
            }
            else if(count == 0){
                ans = x - j;
                break;
            }
            count = 0;
        }

        System.out.println(ans);
    }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int n = sc.nextInt();
        int[] p = new int[n];
        for(int i = 0; i<n; i++){
            p[i] = sc.nextInt();
        }

        Arrays.sort(p);
        int ans = -100000000;
        int ansLow, ansHigh;
        int count = 0;
        int matchNotAns = -1000000000;

        for(int j = 0; j<1000; j++){
            for(int k = 0; k<n; k++){
                if(x - j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
                else if(x + j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
            }
            if(count == 1 && j!=0){
                if(matchNotAns == x - j){
                    ans = x + j;
                }
                else if(matchNotAns == x + j){
                    ans = x - j;
                }
                break;
            }
            else if(count == 0){
                ans = x - j;
                break;
            }
            count = 0;
        }

        System.out.println(ans);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int n = sc.nextInt();
        int[] p = new int[n];
        for(int i = 0; i<n; i++){
            p[i] = sc.nextInt();
        }

        Arrays.sort(p);
        int ans = -100000000;
        int ansLow, ansHigh;
        int count = 0;
        int matchNotAns = -1000000000;

        for(int j = 0; j<1000; j++){
            for(int k = 0; k<n; k++){
                if(x - j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
                else if(x + j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
            }
            if(count == 1 && j!=0){
                if(matchNotAns == x - j){
                    ans = x + j;
                }
                else if(matchNotAns == x + j){
                    ans = x - j;
                }
                break;
            }
            else if(count == 0){
                ans = x - j;
                break;
            }
            count = 0;
        }

        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int n = sc.nextInt();
        int[] p = new int[n];
        for(int i = 0; i<n; i++){
            p[i] = sc.nextInt();
        }

        Arrays.sort(p);
        int ans = -100000000;
        int ansLow, ansHigh;
        int count = 0;
        int matchNotAns = -1000000000;

        for(int j = 0; j<1000; j++){
            for(int k = 0; k<n; k++){
                if(x - j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
                else if(x + j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
            }
            if(count == 1 && j!=0){
                if(matchNotAns == x - j){
                    ans = x + j;
                }
                else if(matchNotAns == x + j){
                    ans = x - j;
                }
                break;
            }
            else if(count == 0){
                ans = x - j;
                break;
            }
            count = 0;
        }

        System.out.println(ans);
    } 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[] p = new int[n]; p new int[n] n for(int i = 0; i<n; i++){
            p[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
            p[i] = sc.nextInt();
        } {
            p[i] = sc.nextInt();
        } p[i] = sc.nextInt() p[i] p i sc.nextInt() sc.nextInt sc Arrays.sort(p) Arrays.sort Arrays p int ans = -100000000; ans -100000000 100000000 int ansLow ansLow ansHigh; ansHigh int count = 0; count 0 int matchNotAns = -1000000000; matchNotAns -1000000000 1000000000 for(int j = 0; j<1000; j++){
            for(int k = 0; k<n; k++){
                if(x - j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
                else if(x + j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
            }
            if(count == 1 && j!=0){
                if(matchNotAns == x - j){
                    ans = x + j;
                }
                else if(matchNotAns == x + j){
                    ans = x - j;
                }
                break;
            }
            else if(count == 0){
                ans = x - j;
                break;
            }
            count = 0;
        } int j = 0; int j = 0; j 0 j<1000 j 1000 j++ j++ j {
            for(int k = 0; k<n; k++){
                if(x - j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
                else if(x + j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
            }
            if(count == 1 && j!=0){
                if(matchNotAns == x - j){
                    ans = x + j;
                }
                else if(matchNotAns == x + j){
                    ans = x - j;
                }
                break;
            }
            else if(count == 0){
                ans = x - j;
                break;
            }
            count = 0;
        } {
            for(int k = 0; k<n; k++){
                if(x - j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
                else if(x + j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
            }
            if(count == 1 && j!=0){
                if(matchNotAns == x - j){
                    ans = x + j;
                }
                else if(matchNotAns == x + j){
                    ans = x - j;
                }
                break;
            }
            else if(count == 0){
                ans = x - j;
                break;
            }
            count = 0;
        } for(int k = 0; k<n; k++){
                if(x - j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
                else if(x + j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
            } int k = 0; int k = 0; k 0 k<n k n k++ k++ k {
                if(x - j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
                else if(x + j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
            } {
                if(x - j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
                else if(x + j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
            } if(x - j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
                else if(x + j == p[k]){
                    count++;
                    matchNotAns = p[k];
                } x - j == p[k] x - j x j p[k] p k {
                    count++;
                    matchNotAns = p[k];
                } count++ count matchNotAns = p[k] matchNotAns p[k] p k if(x + j == p[k]){
                    count++;
                    matchNotAns = p[k];
                } x + j == p[k] x + j x j p[k] p k {
                    count++;
                    matchNotAns = p[k];
                } count++ count matchNotAns = p[k] matchNotAns p[k] p k if(count == 1 && j!=0){
                if(matchNotAns == x - j){
                    ans = x + j;
                }
                else if(matchNotAns == x + j){
                    ans = x - j;
                }
                break;
            }
            else if(count == 0){
                ans = x - j;
                break;
            } count == 1 && j!=0 count == 1 count 1 j!=0 j 0 {
                if(matchNotAns == x - j){
                    ans = x + j;
                }
                else if(matchNotAns == x + j){
                    ans = x - j;
                }
                break;
            } if(matchNotAns == x - j){
                    ans = x + j;
                }
                else if(matchNotAns == x + j){
                    ans = x - j;
                } matchNotAns == x - j matchNotAns x - j x j {
                    ans = x + j;
                } ans = x + j ans x + j x j if(matchNotAns == x + j){
                    ans = x - j;
                } matchNotAns == x + j matchNotAns x + j x j {
                    ans = x - j;
                } ans = x - j ans x - j x j break; if(count == 0){
                ans = x - j;
                break;
            } count == 0 count 0 {
                ans = x - j;
                break;
            } ans = x - j ans x - j x j break; count = 0 count 0 System.out.println(ans) System.out.println System.out System System.out ans 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[] p = new int[n];
        for(int i = 0; i<n; i++){
            p[i] = sc.nextInt();
        }

        Arrays.sort(p);
        int ans = -100000000;
        int ansLow, ansHigh;
        int count = 0;
        int matchNotAns = -1000000000;

        for(int j = 0; j<1000; j++){
            for(int k = 0; k<n; k++){
                if(x - j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
                else if(x + j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
            }
            if(count == 1 && j!=0){
                if(matchNotAns == x - j){
                    ans = x + j;
                }
                else if(matchNotAns == x + j){
                    ans = x - j;
                }
                break;
            }
            else if(count == 0){
                ans = x - j;
                break;
            }
            count = 0;
        }

        System.out.println(ans);
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int n = sc.nextInt();
        int[] p = new int[n];
        for(int i = 0; i<n; i++){
            p[i] = sc.nextInt();
        }

        Arrays.sort(p);
        int ans = -100000000;
        int ansLow, ansHigh;
        int count = 0;
        int matchNotAns = -1000000000;

        for(int j = 0; j<1000; j++){
            for(int k = 0; k<n; k++){
                if(x - j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
                else if(x + j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
            }
            if(count == 1 && j!=0){
                if(matchNotAns == x - j){
                    ans = x + j;
                }
                else if(matchNotAns == x + j){
                    ans = x - j;
                }
                break;
            }
            else if(count == 0){
                ans = x - j;
                break;
            }
            count = 0;
        }

        System.out.println(ans);
    }
} Main
import java.util.Scanner;
import java.util.Arrays;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int n = sc.nextInt();
        int[] p = new int[n];
        for(int i = 0; i<n; i++){
            p[i] = sc.nextInt();
        }

        Arrays.sort(p);
        int ans = -100000000;
        int ansLow, ansHigh;
        int count = 0;
        int matchNotAns = -1000000000;

        for(int j = 0; j<1000; j++){
            for(int k = 0; k<n; k++){
                if(x - j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
                else if(x + j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
            }
            if(count == 1 && j!=0){
                if(matchNotAns == x - j){
                    ans = x + j;
                }
                else if(matchNotAns == x + j){
                    ans = x - j;
                }
                break;
            }
            else if(count == 0){
                ans = x - j;
                break;
            }
            count = 0;
        }

        System.out.println(ans);
    }
}