import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int [] occ = new int[(int)1e5+1];
		for (int i = 0; i < n; ++i) {
			++occ[sc.nextInt()];
		}
		int cnt = n/2, i = 0;
		while(cnt > 0) {
			int val = Math.min(cnt, occ[i]);
			cnt -= val;
			occ[i] -= val;
			++i;
		}
		--i;
		// i contains (n/2)th element
		int k = 0;
		while(i < occ.length && occ[i++] == 0) ++k;
		out.println(k);
		out.flush();
		out.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.PrintWriter; PrintWriter java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int [] occ = new int[(int)1e5+1];
		for (int i = 0; i < n; ++i) {
			++occ[sc.nextInt()];
		}
		int cnt = n/2, i = 0;
		while(cnt > 0) {
			int val = Math.min(cnt, occ[i]);
			cnt -= val;
			occ[i] -= val;
			++i;
		}
		--i;
		// i contains (n/2)th element
		int k = 0;
		while(i < occ.length && occ[i++] == 0) ++k;
		out.println(k);
		out.flush();
		out.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}
	}
} Main public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int [] occ = new int[(int)1e5+1];
		for (int i = 0; i < n; ++i) {
			++occ[sc.nextInt()];
		}
		int cnt = n/2, i = 0;
		while(cnt > 0) {
			int val = Math.min(cnt, occ[i]);
			cnt -= val;
			occ[i] -= val;
			++i;
		}
		--i;
		// i contains (n/2)th element
		int k = 0;
		while(i < occ.length && occ[i++] == 0) ++k;
		out.println(k);
		out.flush();
		out.close();
	} main {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int [] occ = new int[(int)1e5+1];
		for (int i = 0; i < n; ++i) {
			++occ[sc.nextInt()];
		}
		int cnt = n/2, i = 0;
		while(cnt > 0) {
			int val = Math.min(cnt, occ[i]);
			cnt -= val;
			occ[i] -= val;
			++i;
		}
		--i;
		// i contains (n/2)th element
		int k = 0;
		while(i < occ.length && occ[i++] == 0) ++k;
		out.println(k);
		out.flush();
		out.close();
	} Scanner sc = new Scanner(); sc new Scanner() PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int [] occ = new int[(int)1e5+1]; occ new int[(int)1e5+1] (int)1e5+1 (int)1e5 1 for (int i = 0; i < n; ++i) {
			++occ[sc.nextInt()];
		} int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
			++occ[sc.nextInt()];
		} {
			++occ[sc.nextInt()];
		} ++occ[sc.nextInt()] occ[sc.nextInt()] occ sc.nextInt() sc.nextInt sc int cnt = n/2 cnt n/2 n 2 i = 0; i 0 while(cnt > 0) {
			int val = Math.min(cnt, occ[i]);
			cnt -= val;
			occ[i] -= val;
			++i;
		} cnt > 0 cnt 0 {
			int val = Math.min(cnt, occ[i]);
			cnt -= val;
			occ[i] -= val;
			++i;
		} int val = Math.min(cnt, occ[i]); val Math.min(cnt, occ[i]) Math.min Math cnt occ[i] occ i cnt -= val cnt val occ[i] -= val occ[i] occ i val ++i i --i i int k = 0; k 0 while(i < occ.length && occ[i++] == 0) ++k; i < occ.length && occ[i++] == 0 i < occ.length i occ.length occ occ.length occ[i++] == 0 occ[i++] occ i++ i 0 ++k k out.println(k) out.println out k out.flush() out.flush out out.close() out.close out String[] args args static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}
	} Scanner BufferedReader br; br StringTokenizer st; st public Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		} Scanner {
			br = new BufferedReader(new InputStreamReader(System.in));
		} br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) public String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		} next {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		} while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			} st == null || !st.hasMoreTokens() st == null st null !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st {
				st = new StringTokenizer(br.readLine());
			} st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		} nextInt {
			return Integer.parseInt(next());
		} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int [] occ = new int[(int)1e5+1];
		for (int i = 0; i < n; ++i) {
			++occ[sc.nextInt()];
		}
		int cnt = n/2, i = 0;
		while(cnt > 0) {
			int val = Math.min(cnt, occ[i]);
			cnt -= val;
			occ[i] -= val;
			++i;
		}
		--i;
		// i contains (n/2)th element
		int k = 0;
		while(i < occ.length && occ[i++] == 0) ++k;
		out.println(k);
		out.flush();
		out.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}
	}
} public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int [] occ = new int[(int)1e5+1];
		for (int i = 0; i < n; ++i) {
			++occ[sc.nextInt()];
		}
		int cnt = n/2, i = 0;
		while(cnt > 0) {
			int val = Math.min(cnt, occ[i]);
			cnt -= val;
			occ[i] -= val;
			++i;
		}
		--i;
		// i contains (n/2)th element
		int k = 0;
		while(i < occ.length && occ[i++] == 0) ++k;
		out.println(k);
		out.flush();
		out.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int [] occ = new int[(int)1e5+1];
		for (int i = 0; i < n; ++i) {
			++occ[sc.nextInt()];
		}
		int cnt = n/2, i = 0;
		while(cnt > 0) {
			int val = Math.min(cnt, occ[i]);
			cnt -= val;
			occ[i] -= val;
			++i;
		}
		--i;
		// i contains (n/2)th element
		int k = 0;
		while(i < occ.length && occ[i++] == 0) ++k;
		out.println(k);
		out.flush();
		out.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}
	}
}
