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();
		if (n == 0) {
			System.out.println(x);
			return;
		}
		Set<Integer> p = new HashSet<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		sc.close();

		Integer underPos = null;
		Integer upwardPos = null;

		// 下方向探索
		int startPos = x;
		while (underPos == null) {
			if (p.contains(startPos) != true) {
				underPos = startPos;
			}
			startPos--;
		}
		// 上方向探索
		startPos = x;
		while (upwardPos == null) {
			if (p.contains(startPos) != true) {
				upwardPos = startPos;
			}
			startPos++;
		}
		// 差分を出す
		int underDist = Math.abs(x - underPos);
		int upwardDist = Math.abs(x - upwardPos);
		if (underDist == upwardDist) {
			System.out.println(underPos);
			return;
		}

		if (underDist < upwardDist) {
			System.out.println(underPos);
		} else {
			System.out.println(upwardPos);
		}

	}
} 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();
		if (n == 0) {
			System.out.println(x);
			return;
		}
		Set<Integer> p = new HashSet<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		sc.close();

		Integer underPos = null;
		Integer upwardPos = null;

		// 下方向探索
		int startPos = x;
		while (underPos == null) {
			if (p.contains(startPos) != true) {
				underPos = startPos;
			}
			startPos--;
		}
		// 上方向探索
		startPos = x;
		while (upwardPos == null) {
			if (p.contains(startPos) != true) {
				upwardPos = startPos;
			}
			startPos++;
		}
		// 差分を出す
		int underDist = Math.abs(x - underPos);
		int upwardDist = Math.abs(x - upwardPos);
		if (underDist == upwardDist) {
			System.out.println(underPos);
			return;
		}

		if (underDist < upwardDist) {
			System.out.println(underPos);
		} else {
			System.out.println(upwardPos);
		}

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

		int x = sc.nextInt();
		int n = sc.nextInt();
		if (n == 0) {
			System.out.println(x);
			return;
		}
		Set<Integer> p = new HashSet<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		sc.close();

		Integer underPos = null;
		Integer upwardPos = null;

		// 下方向探索
		int startPos = x;
		while (underPos == null) {
			if (p.contains(startPos) != true) {
				underPos = startPos;
			}
			startPos--;
		}
		// 上方向探索
		startPos = x;
		while (upwardPos == null) {
			if (p.contains(startPos) != true) {
				upwardPos = startPos;
			}
			startPos++;
		}
		// 差分を出す
		int underDist = Math.abs(x - underPos);
		int upwardDist = Math.abs(x - upwardPos);
		if (underDist == upwardDist) {
			System.out.println(underPos);
			return;
		}

		if (underDist < upwardDist) {
			System.out.println(underPos);
		} else {
			System.out.println(upwardPos);
		}

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

		int x = sc.nextInt();
		int n = sc.nextInt();
		if (n == 0) {
			System.out.println(x);
			return;
		}
		Set<Integer> p = new HashSet<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		sc.close();

		Integer underPos = null;
		Integer upwardPos = null;

		// 下方向探索
		int startPos = x;
		while (underPos == null) {
			if (p.contains(startPos) != true) {
				underPos = startPos;
			}
			startPos--;
		}
		// 上方向探索
		startPos = x;
		while (upwardPos == null) {
			if (p.contains(startPos) != true) {
				upwardPos = startPos;
			}
			startPos++;
		}
		// 差分を出す
		int underDist = Math.abs(x - underPos);
		int upwardDist = Math.abs(x - upwardPos);
		if (underDist == upwardDist) {
			System.out.println(underPos);
			return;
		}

		if (underDist < upwardDist) {
			System.out.println(underPos);
		} else {
			System.out.println(upwardPos);
		}

	} 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 if (n == 0) {
			System.out.println(x);
			return;
		} n == 0 n 0 {
			System.out.println(x);
			return;
		} System.out.println(x) System.out.println System.out System System.out x return; 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 sc.close() sc.close sc Integer underPos = null; underPos null Integer upwardPos = null; upwardPos null int startPos = x; startPos x while (underPos == null) {
			if (p.contains(startPos) != true) {
				underPos = startPos;
			}
			startPos--;
		} underPos == null underPos null {
			if (p.contains(startPos) != true) {
				underPos = startPos;
			}
			startPos--;
		} if (p.contains(startPos) != true) {
				underPos = startPos;
			} p.contains(startPos) != true p.contains(startPos) p.contains p startPos true {
				underPos = startPos;
			} underPos = startPos underPos startPos startPos-- startPos startPos = x startPos x while (upwardPos == null) {
			if (p.contains(startPos) != true) {
				upwardPos = startPos;
			}
			startPos++;
		} upwardPos == null upwardPos null {
			if (p.contains(startPos) != true) {
				upwardPos = startPos;
			}
			startPos++;
		} if (p.contains(startPos) != true) {
				upwardPos = startPos;
			} p.contains(startPos) != true p.contains(startPos) p.contains p startPos true {
				upwardPos = startPos;
			} upwardPos = startPos upwardPos startPos startPos++ startPos int underDist = Math.abs(x - underPos); underDist Math.abs(x - underPos) Math.abs Math x - underPos x underPos int upwardDist = Math.abs(x - upwardPos); upwardDist Math.abs(x - upwardPos) Math.abs Math x - upwardPos x upwardPos if (underDist == upwardDist) {
			System.out.println(underPos);
			return;
		} underDist == upwardDist underDist upwardDist {
			System.out.println(underPos);
			return;
		} System.out.println(underPos) System.out.println System.out System System.out underPos return; if (underDist < upwardDist) {
			System.out.println(underPos);
		} else {
			System.out.println(upwardPos);
		} underDist < upwardDist underDist upwardDist {
			System.out.println(underPos);
		} System.out.println(underPos) System.out.println System.out System System.out underPos {
			System.out.println(upwardPos);
		} System.out.println(upwardPos) System.out.println System.out System System.out upwardPos 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();
		if (n == 0) {
			System.out.println(x);
			return;
		}
		Set<Integer> p = new HashSet<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		sc.close();

		Integer underPos = null;
		Integer upwardPos = null;

		// 下方向探索
		int startPos = x;
		while (underPos == null) {
			if (p.contains(startPos) != true) {
				underPos = startPos;
			}
			startPos--;
		}
		// 上方向探索
		startPos = x;
		while (upwardPos == null) {
			if (p.contains(startPos) != true) {
				upwardPos = startPos;
			}
			startPos++;
		}
		// 差分を出す
		int underDist = Math.abs(x - underPos);
		int upwardDist = Math.abs(x - upwardPos);
		if (underDist == upwardDist) {
			System.out.println(underPos);
			return;
		}

		if (underDist < upwardDist) {
			System.out.println(underPos);
		} else {
			System.out.println(upwardPos);
		}

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

		int x = sc.nextInt();
		int n = sc.nextInt();
		if (n == 0) {
			System.out.println(x);
			return;
		}
		Set<Integer> p = new HashSet<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		sc.close();

		Integer underPos = null;
		Integer upwardPos = null;

		// 下方向探索
		int startPos = x;
		while (underPos == null) {
			if (p.contains(startPos) != true) {
				underPos = startPos;
			}
			startPos--;
		}
		// 上方向探索
		startPos = x;
		while (upwardPos == null) {
			if (p.contains(startPos) != true) {
				upwardPos = startPos;
			}
			startPos++;
		}
		// 差分を出す
		int underDist = Math.abs(x - underPos);
		int upwardDist = Math.abs(x - upwardPos);
		if (underDist == upwardDist) {
			System.out.println(underPos);
			return;
		}

		if (underDist < upwardDist) {
			System.out.println(underPos);
		} else {
			System.out.println(upwardPos);
		}

	}
} 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();
		if (n == 0) {
			System.out.println(x);
			return;
		}
		Set<Integer> p = new HashSet<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}
		sc.close();

		Integer underPos = null;
		Integer upwardPos = null;

		// 下方向探索
		int startPos = x;
		while (underPos == null) {
			if (p.contains(startPos) != true) {
				underPos = startPos;
			}
			startPos--;
		}
		// 上方向探索
		startPos = x;
		while (upwardPos == null) {
			if (p.contains(startPos) != true) {
				upwardPos = startPos;
			}
			startPos++;
		}
		// 差分を出す
		int underDist = Math.abs(x - underPos);
		int upwardDist = Math.abs(x - upwardPos);
		if (underDist == upwardDist) {
			System.out.println(underPos);
			return;
		}

		if (underDist < upwardDist) {
			System.out.println(underPos);
		} else {
			System.out.println(upwardPos);
		}

	}
}
