import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
		int N = scanner.nextInt();
		List<Integer> nums = new ArrayList<Integer>();
		List<Integer> data = new ArrayList<Integer>();
		boolean b = true;

		for(int i = 0; i < N;i++) {
			nums.add(scanner.nextInt());
			if(nums.get(i) == X)b = false;
		}
		if(b) {
			System.out.println(X);
			System.exit(0);
		}
		for(int i = 0;i<=101;i++) {
			data.add(i);
		}
		for(int i = 0; i < nums.size();i++) {
			for(int j = 0; j<data.size();j++) {
				if(data.get(j) != X && nums.get(i) == data.get(j)) {
					data.remove(j);
				}
			}
		}
		int Xindex = data.indexOf(X);
		if(X-data.get(Xindex-1)<=data.get(Xindex+1)-X) {
			System.out.println(data.get(Xindex-1));
		}else {
			System.out.println(data.get(Xindex+1));
		}
		scanner.close();
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
		int N = scanner.nextInt();
		List<Integer> nums = new ArrayList<Integer>();
		List<Integer> data = new ArrayList<Integer>();
		boolean b = true;

		for(int i = 0; i < N;i++) {
			nums.add(scanner.nextInt());
			if(nums.get(i) == X)b = false;
		}
		if(b) {
			System.out.println(X);
			System.exit(0);
		}
		for(int i = 0;i<=101;i++) {
			data.add(i);
		}
		for(int i = 0; i < nums.size();i++) {
			for(int j = 0; j<data.size();j++) {
				if(data.get(j) != X && nums.get(i) == data.get(j)) {
					data.remove(j);
				}
			}
		}
		int Xindex = data.indexOf(X);
		if(X-data.get(Xindex-1)<=data.get(Xindex+1)-X) {
			System.out.println(data.get(Xindex-1));
		}else {
			System.out.println(data.get(Xindex+1));
		}
		scanner.close();
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
		int N = scanner.nextInt();
		List<Integer> nums = new ArrayList<Integer>();
		List<Integer> data = new ArrayList<Integer>();
		boolean b = true;

		for(int i = 0; i < N;i++) {
			nums.add(scanner.nextInt());
			if(nums.get(i) == X)b = false;
		}
		if(b) {
			System.out.println(X);
			System.exit(0);
		}
		for(int i = 0;i<=101;i++) {
			data.add(i);
		}
		for(int i = 0; i < nums.size();i++) {
			for(int j = 0; j<data.size();j++) {
				if(data.get(j) != X && nums.get(i) == data.get(j)) {
					data.remove(j);
				}
			}
		}
		int Xindex = data.indexOf(X);
		if(X-data.get(Xindex-1)<=data.get(Xindex+1)-X) {
			System.out.println(data.get(Xindex-1));
		}else {
			System.out.println(data.get(Xindex+1));
		}
		scanner.close();
	} main {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
		int N = scanner.nextInt();
		List<Integer> nums = new ArrayList<Integer>();
		List<Integer> data = new ArrayList<Integer>();
		boolean b = true;

		for(int i = 0; i < N;i++) {
			nums.add(scanner.nextInt());
			if(nums.get(i) == X)b = false;
		}
		if(b) {
			System.out.println(X);
			System.exit(0);
		}
		for(int i = 0;i<=101;i++) {
			data.add(i);
		}
		for(int i = 0; i < nums.size();i++) {
			for(int j = 0; j<data.size();j++) {
				if(data.get(j) != X && nums.get(i) == data.get(j)) {
					data.remove(j);
				}
			}
		}
		int Xindex = data.indexOf(X);
		if(X-data.get(Xindex-1)<=data.get(Xindex+1)-X) {
			System.out.println(data.get(Xindex-1));
		}else {
			System.out.println(data.get(Xindex+1));
		}
		scanner.close();
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int X = scanner.nextInt(); X scanner.nextInt() scanner.nextInt scanner int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner List<Integer> nums = new ArrayList<Integer>(); nums new ArrayList<Integer>() List<Integer> data = new ArrayList<Integer>(); data new ArrayList<Integer>() boolean b = true; b true for(int i = 0; i < N;i++) {
			nums.add(scanner.nextInt());
			if(nums.get(i) == X)b = false;
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			nums.add(scanner.nextInt());
			if(nums.get(i) == X)b = false;
		} {
			nums.add(scanner.nextInt());
			if(nums.get(i) == X)b = false;
		} nums.add(scanner.nextInt()) nums.add nums scanner.nextInt() scanner.nextInt scanner if(nums.get(i) == X)b = false; nums.get(i) == X nums.get(i) nums.get nums i X b = false b false if(b) {
			System.out.println(X);
			System.exit(0);
		} b {
			System.out.println(X);
			System.exit(0);
		} System.out.println(X) System.out.println System.out System System.out X System.exit(0) System.exit System 0 for(int i = 0;i<=101;i++) {
			data.add(i);
		} int i = 0; int i = 0; i 0 i<=101 i 101 i++ i++ i {
			data.add(i);
		} {
			data.add(i);
		} data.add(i) data.add data i for(int i = 0; i < nums.size();i++) {
			for(int j = 0; j<data.size();j++) {
				if(data.get(j) != X && nums.get(i) == data.get(j)) {
					data.remove(j);
				}
			}
		} int i = 0; int i = 0; i 0 i < nums.size() i nums.size() nums.size nums i++ i++ i {
			for(int j = 0; j<data.size();j++) {
				if(data.get(j) != X && nums.get(i) == data.get(j)) {
					data.remove(j);
				}
			}
		} {
			for(int j = 0; j<data.size();j++) {
				if(data.get(j) != X && nums.get(i) == data.get(j)) {
					data.remove(j);
				}
			}
		} for(int j = 0; j<data.size();j++) {
				if(data.get(j) != X && nums.get(i) == data.get(j)) {
					data.remove(j);
				}
			} int j = 0; int j = 0; j 0 j<data.size() j data.size() data.size data j++ j++ j {
				if(data.get(j) != X && nums.get(i) == data.get(j)) {
					data.remove(j);
				}
			} {
				if(data.get(j) != X && nums.get(i) == data.get(j)) {
					data.remove(j);
				}
			} if(data.get(j) != X && nums.get(i) == data.get(j)) {
					data.remove(j);
				} data.get(j) != X && nums.get(i) == data.get(j) data.get(j) != X data.get(j) data.get data j X nums.get(i) == data.get(j) nums.get(i) nums.get nums i data.get(j) data.get data j {
					data.remove(j);
				} data.remove(j) data.remove data j int Xindex = data.indexOf(X); Xindex data.indexOf(X) data.indexOf data X if(X-data.get(Xindex-1)<=data.get(Xindex+1)-X) {
			System.out.println(data.get(Xindex-1));
		}else {
			System.out.println(data.get(Xindex+1));
		} X-data.get(Xindex-1)<=data.get(Xindex+1)-X X-data.get(Xindex-1) X data.get(Xindex-1) data.get data Xindex-1 Xindex 1 data.get(Xindex+1)-X data.get(Xindex+1) data.get data Xindex+1 Xindex 1 X {
			System.out.println(data.get(Xindex-1));
		} System.out.println(data.get(Xindex-1)) System.out.println System.out System System.out data.get(Xindex-1) data.get data Xindex-1 Xindex 1 {
			System.out.println(data.get(Xindex+1));
		} System.out.println(data.get(Xindex+1)) System.out.println System.out System System.out data.get(Xindex+1) data.get data Xindex+1 Xindex 1 scanner.close() scanner.close scanner String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
		int N = scanner.nextInt();
		List<Integer> nums = new ArrayList<Integer>();
		List<Integer> data = new ArrayList<Integer>();
		boolean b = true;

		for(int i = 0; i < N;i++) {
			nums.add(scanner.nextInt());
			if(nums.get(i) == X)b = false;
		}
		if(b) {
			System.out.println(X);
			System.exit(0);
		}
		for(int i = 0;i<=101;i++) {
			data.add(i);
		}
		for(int i = 0; i < nums.size();i++) {
			for(int j = 0; j<data.size();j++) {
				if(data.get(j) != X && nums.get(i) == data.get(j)) {
					data.remove(j);
				}
			}
		}
		int Xindex = data.indexOf(X);
		if(X-data.get(Xindex-1)<=data.get(Xindex+1)-X) {
			System.out.println(data.get(Xindex-1));
		}else {
			System.out.println(data.get(Xindex+1));
		}
		scanner.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
		int N = scanner.nextInt();
		List<Integer> nums = new ArrayList<Integer>();
		List<Integer> data = new ArrayList<Integer>();
		boolean b = true;

		for(int i = 0; i < N;i++) {
			nums.add(scanner.nextInt());
			if(nums.get(i) == X)b = false;
		}
		if(b) {
			System.out.println(X);
			System.exit(0);
		}
		for(int i = 0;i<=101;i++) {
			data.add(i);
		}
		for(int i = 0; i < nums.size();i++) {
			for(int j = 0; j<data.size();j++) {
				if(data.get(j) != X && nums.get(i) == data.get(j)) {
					data.remove(j);
				}
			}
		}
		int Xindex = data.indexOf(X);
		if(X-data.get(Xindex-1)<=data.get(Xindex+1)-X) {
			System.out.println(data.get(Xindex-1));
		}else {
			System.out.println(data.get(Xindex+1));
		}
		scanner.close();
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
		int N = scanner.nextInt();
		List<Integer> nums = new ArrayList<Integer>();
		List<Integer> data = new ArrayList<Integer>();
		boolean b = true;

		for(int i = 0; i < N;i++) {
			nums.add(scanner.nextInt());
			if(nums.get(i) == X)b = false;
		}
		if(b) {
			System.out.println(X);
			System.exit(0);
		}
		for(int i = 0;i<=101;i++) {
			data.add(i);
		}
		for(int i = 0; i < nums.size();i++) {
			for(int j = 0; j<data.size();j++) {
				if(data.get(j) != X && nums.get(i) == data.get(j)) {
					data.remove(j);
				}
			}
		}
		int Xindex = data.indexOf(X);
		if(X-data.get(Xindex-1)<=data.get(Xindex+1)-X) {
			System.out.println(data.get(Xindex-1));
		}else {
			System.out.println(data.get(Xindex+1));
		}
		scanner.close();
	}
}
