import 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();
        
        HashMap<Integer, Integer> data = new HashMap<>();
        
        for(int i = 0; i<n;i++) {
          data.put(sc.nextInt(), 1);
        }
        
        int output = x;
        int diff = 0;
        
        while(true) {
          int val = x-diff;
          int val2 = x+diff;
          if(data.get(val) == null) {
            output = val;
            break;
          }
          
          if(data.get(val2) == null) {
            output = val2;
            break;
          }
          diff++;
        }
        
        System.out.println(output);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int n = sc.nextInt();
        
        HashMap<Integer, Integer> data = new HashMap<>();
        
        for(int i = 0; i<n;i++) {
          data.put(sc.nextInt(), 1);
        }
        
        int output = x;
        int diff = 0;
        
        while(true) {
          int val = x-diff;
          int val2 = x+diff;
          if(data.get(val) == null) {
            output = val;
            break;
          }
          
          if(data.get(val2) == null) {
            output = val2;
            break;
          }
          diff++;
        }
        
        System.out.println(output);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int n = sc.nextInt();
        
        HashMap<Integer, Integer> data = new HashMap<>();
        
        for(int i = 0; i<n;i++) {
          data.put(sc.nextInt(), 1);
        }
        
        int output = x;
        int diff = 0;
        
        while(true) {
          int val = x-diff;
          int val2 = x+diff;
          if(data.get(val) == null) {
            output = val;
            break;
          }
          
          if(data.get(val2) == null) {
            output = val2;
            break;
          }
          diff++;
        }
        
        System.out.println(output);
    } main {
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int n = sc.nextInt();
        
        HashMap<Integer, Integer> data = new HashMap<>();
        
        for(int i = 0; i<n;i++) {
          data.put(sc.nextInt(), 1);
        }
        
        int output = x;
        int diff = 0;
        
        while(true) {
          int val = x-diff;
          int val2 = x+diff;
          if(data.get(val) == null) {
            output = val;
            break;
          }
          
          if(data.get(val2) == null) {
            output = val2;
            break;
          }
          diff++;
        }
        
        System.out.println(output);
    } 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 HashMap<Integer, Integer> data = new HashMap<>(); data new HashMap<>() for(int i = 0; i<n;i++) {
          data.put(sc.nextInt(), 1);
        } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
          data.put(sc.nextInt(), 1);
        } {
          data.put(sc.nextInt(), 1);
        } data.put(sc.nextInt(), 1) data.put data sc.nextInt() sc.nextInt sc 1 int output = x; output x int diff = 0; diff 0 while(true) {
          int val = x-diff;
          int val2 = x+diff;
          if(data.get(val) == null) {
            output = val;
            break;
          }
          
          if(data.get(val2) == null) {
            output = val2;
            break;
          }
          diff++;
        } true {
          int val = x-diff;
          int val2 = x+diff;
          if(data.get(val) == null) {
            output = val;
            break;
          }
          
          if(data.get(val2) == null) {
            output = val2;
            break;
          }
          diff++;
        } int val = x-diff; val x-diff x diff int val2 = x+diff; val2 x+diff x diff if(data.get(val) == null) {
            output = val;
            break;
          } data.get(val) == null data.get(val) data.get data val null {
            output = val;
            break;
          } output = val output val break; if(data.get(val2) == null) {
            output = val2;
            break;
          } data.get(val2) == null data.get(val2) data.get data val2 null {
            output = val2;
            break;
          } output = val2 output val2 break; diff++ diff System.out.println(output) System.out.println System.out System System.out output 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();
        
        HashMap<Integer, Integer> data = new HashMap<>();
        
        for(int i = 0; i<n;i++) {
          data.put(sc.nextInt(), 1);
        }
        
        int output = x;
        int diff = 0;
        
        while(true) {
          int val = x-diff;
          int val2 = x+diff;
          if(data.get(val) == null) {
            output = val;
            break;
          }
          
          if(data.get(val2) == null) {
            output = val2;
            break;
          }
          diff++;
        }
        
        System.out.println(output);
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int n = sc.nextInt();
        
        HashMap<Integer, Integer> data = new HashMap<>();
        
        for(int i = 0; i<n;i++) {
          data.put(sc.nextInt(), 1);
        }
        
        int output = x;
        int diff = 0;
        
        while(true) {
          int val = x-diff;
          int val2 = x+diff;
          if(data.get(val) == null) {
            output = val;
            break;
          }
          
          if(data.get(val2) == null) {
            output = val2;
            break;
          }
          diff++;
        }
        
        System.out.println(output);
    }
} Main
import 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();
        
        HashMap<Integer, Integer> data = new HashMap<>();
        
        for(int i = 0; i<n;i++) {
          data.put(sc.nextInt(), 1);
        }
        
        int output = x;
        int diff = 0;
        
        while(true) {
          int val = x-diff;
          int val2 = x+diff;
          if(data.get(val) == null) {
            output = val;
            break;
          }
          
          if(data.get(val2) == null) {
            output = val2;
            break;
          }
          diff++;
        }
        
        System.out.println(output);
    }
}
