import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		Set<Integer> p = new HashSet<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		
		int distance = 0;
		while(true) {
			if(p.contains(Integer.valueOf(x - distance)) == false) {
				System.out.println(x - distance);
				break;
			} else if(p.contains(Integer.valueOf(x + distance)) == false) {
				System.out.println(x + distance);
				break;
			}
			distance++;
		}
	}
} import java.util.HashSet; HashSet java.util import java.util.Scanner; Scanner java.util import java.util.Set; Set 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();
		Set<Integer> p = new HashSet<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		
		int distance = 0;
		while(true) {
			if(p.contains(Integer.valueOf(x - distance)) == false) {
				System.out.println(x - distance);
				break;
			} else if(p.contains(Integer.valueOf(x + distance)) == false) {
				System.out.println(x + distance);
				break;
			}
			distance++;
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		Set<Integer> p = new HashSet<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		
		int distance = 0;
		while(true) {
			if(p.contains(Integer.valueOf(x - distance)) == false) {
				System.out.println(x - distance);
				break;
			} else if(p.contains(Integer.valueOf(x + distance)) == false) {
				System.out.println(x + distance);
				break;
			}
			distance++;
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		Set<Integer> p = new HashSet<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		
		int distance = 0;
		while(true) {
			if(p.contains(Integer.valueOf(x - distance)) == false) {
				System.out.println(x - distance);
				break;
			} else if(p.contains(Integer.valueOf(x + distance)) == false) {
				System.out.println(x + distance);
				break;
			}
			distance++;
		}
	} 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 Set<Integer> p = new HashSet<>(); p new HashSet<>() for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			p.add(sc.nextInt());
		} {
			p.add(sc.nextInt());
		} p.add(sc.nextInt()) p.add p sc.nextInt() sc.nextInt sc int distance = 0; distance 0 while(true) {
			if(p.contains(Integer.valueOf(x - distance)) == false) {
				System.out.println(x - distance);
				break;
			} else if(p.contains(Integer.valueOf(x + distance)) == false) {
				System.out.println(x + distance);
				break;
			}
			distance++;
		} true {
			if(p.contains(Integer.valueOf(x - distance)) == false) {
				System.out.println(x - distance);
				break;
			} else if(p.contains(Integer.valueOf(x + distance)) == false) {
				System.out.println(x + distance);
				break;
			}
			distance++;
		} if(p.contains(Integer.valueOf(x - distance)) == false) {
				System.out.println(x - distance);
				break;
			} else if(p.contains(Integer.valueOf(x + distance)) == false) {
				System.out.println(x + distance);
				break;
			} p.contains(Integer.valueOf(x - distance)) == false p.contains(Integer.valueOf(x - distance)) p.contains p Integer.valueOf(x - distance) Integer.valueOf Integer x - distance x distance false {
				System.out.println(x - distance);
				break;
			} System.out.println(x - distance) System.out.println System.out System System.out x - distance x distance break; if(p.contains(Integer.valueOf(x + distance)) == false) {
				System.out.println(x + distance);
				break;
			} p.contains(Integer.valueOf(x + distance)) == false p.contains(Integer.valueOf(x + distance)) p.contains p Integer.valueOf(x + distance) Integer.valueOf Integer x + distance x distance false {
				System.out.println(x + distance);
				break;
			} System.out.println(x + distance) System.out.println System.out System System.out x + distance x distance break; distance++ distance 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();
		Set<Integer> p = new HashSet<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		
		int distance = 0;
		while(true) {
			if(p.contains(Integer.valueOf(x - distance)) == false) {
				System.out.println(x - distance);
				break;
			} else if(p.contains(Integer.valueOf(x + distance)) == false) {
				System.out.println(x + distance);
				break;
			}
			distance++;
		}
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		Set<Integer> p = new HashSet<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		
		int distance = 0;
		while(true) {
			if(p.contains(Integer.valueOf(x - distance)) == false) {
				System.out.println(x - distance);
				break;
			} else if(p.contains(Integer.valueOf(x + distance)) == false) {
				System.out.println(x + distance);
				break;
			}
			distance++;
		}
	}
} Main
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		Set<Integer> p = new HashSet<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		
		int distance = 0;
		while(true) {
			if(p.contains(Integer.valueOf(x - distance)) == false) {
				System.out.println(x - distance);
				break;
			} else if(p.contains(Integer.valueOf(x + distance)) == false) {
				System.out.println(x + distance);
				break;
			}
			distance++;
		}
	}
}
