
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] d = new int[100001];
			for (int i = 0; i < n; i++) {
				d[sc.nextInt()]++;
			}

			int tmp = 0;
			int cnt = 0;
			for (int i = 0; i < 100001; i++) {
				tmp += d[i];
				if (n == tmp * 2) {
					cnt++;
				} else if(n < tmp * 2) {
					break;
				}
			}
			System.out.println(cnt);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] d = new int[100001];
			for (int i = 0; i < n; i++) {
				d[sc.nextInt()]++;
			}

			int tmp = 0;
			int cnt = 0;
			for (int i = 0; i < 100001; i++) {
				tmp += d[i];
				if (n == tmp * 2) {
					cnt++;
				} else if(n < tmp * 2) {
					break;
				}
			}
			System.out.println(cnt);
		}
	}
} Main public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] d = new int[100001];
			for (int i = 0; i < n; i++) {
				d[sc.nextInt()]++;
			}

			int tmp = 0;
			int cnt = 0;
			for (int i = 0; i < 100001; i++) {
				tmp += d[i];
				if (n == tmp * 2) {
					cnt++;
				} else if(n < tmp * 2) {
					break;
				}
			}
			System.out.println(cnt);
		}
	} main {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] d = new int[100001];
			for (int i = 0; i < n; i++) {
				d[sc.nextInt()]++;
			}

			int tmp = 0;
			int cnt = 0;
			for (int i = 0; i < 100001; i++) {
				tmp += d[i];
				if (n == tmp * 2) {
					cnt++;
				} else if(n < tmp * 2) {
					break;
				}
			}
			System.out.println(cnt);
		}
	} try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] d = new int[100001];
			for (int i = 0; i < n; i++) {
				d[sc.nextInt()]++;
			}

			int tmp = 0;
			int cnt = 0;
			for (int i = 0; i < 100001; i++) {
				tmp += d[i];
				if (n == tmp * 2) {
					cnt++;
				} else if(n < tmp * 2) {
					break;
				}
			}
			System.out.println(cnt);
		} {
			int n = sc.nextInt();
			int[] d = new int[100001];
			for (int i = 0; i < n; i++) {
				d[sc.nextInt()]++;
			}

			int tmp = 0;
			int cnt = 0;
			for (int i = 0; i < 100001; i++) {
				tmp += d[i];
				if (n == tmp * 2) {
					cnt++;
				} else if(n < tmp * 2) {
					break;
				}
			}
			System.out.println(cnt);
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] d = new int[100001]; d new int[100001] 100001 for (int i = 0; i < n; i++) {
				d[sc.nextInt()]++;
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				d[sc.nextInt()]++;
			} {
				d[sc.nextInt()]++;
			} d[sc.nextInt()]++ d[sc.nextInt()] d sc.nextInt() sc.nextInt sc int tmp = 0; tmp 0 int cnt = 0; cnt 0 for (int i = 0; i < 100001; i++) {
				tmp += d[i];
				if (n == tmp * 2) {
					cnt++;
				} else if(n < tmp * 2) {
					break;
				}
			} int i = 0; int i = 0; i 0 i < 100001 i 100001 i++ i++ i {
				tmp += d[i];
				if (n == tmp * 2) {
					cnt++;
				} else if(n < tmp * 2) {
					break;
				}
			} {
				tmp += d[i];
				if (n == tmp * 2) {
					cnt++;
				} else if(n < tmp * 2) {
					break;
				}
			} tmp += d[i] tmp d[i] d i if (n == tmp * 2) {
					cnt++;
				} else if(n < tmp * 2) {
					break;
				} n == tmp * 2 n tmp * 2 tmp 2 {
					cnt++;
				} cnt++ cnt if(n < tmp * 2) {
					break;
				} n < tmp * 2 n tmp * 2 tmp 2 {
					break;
				} break; System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] d = new int[100001];
			for (int i = 0; i < n; i++) {
				d[sc.nextInt()]++;
			}

			int tmp = 0;
			int cnt = 0;
			for (int i = 0; i < 100001; i++) {
				tmp += d[i];
				if (n == tmp * 2) {
					cnt++;
				} else if(n < tmp * 2) {
					break;
				}
			}
			System.out.println(cnt);
		}
	}
} public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] d = new int[100001];
			for (int i = 0; i < n; i++) {
				d[sc.nextInt()]++;
			}

			int tmp = 0;
			int cnt = 0;
			for (int i = 0; i < 100001; i++) {
				tmp += d[i];
				if (n == tmp * 2) {
					cnt++;
				} else if(n < tmp * 2) {
					break;
				}
			}
			System.out.println(cnt);
		}
	}
} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] d = new int[100001];
			for (int i = 0; i < n; i++) {
				d[sc.nextInt()]++;
			}

			int tmp = 0;
			int cnt = 0;
			for (int i = 0; i < 100001; i++) {
				tmp += d[i];
				if (n == tmp * 2) {
					cnt++;
				} else if(n < tmp * 2) {
					break;
				}
			}
			System.out.println(cnt);
		}
	}
}
