
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] d = new int[N];

		for(int i = 0; i < N; i++) {
			String line = sc.next();
			d[i] = Integer.parseInt(line);
		}

		int K = 0;
		int count = 0;
		int countLeft = 0;
		int countRight = N;
		Arrays.sort(d);

		for(int i = 0; i < N; i++) {
			countLeft++;
			countRight--;
			if(countLeft == countRight) {
				K = d[i];
				while(d[i] <= K && K < d[i+1]) {
					K++;
					count++;
				}
				break;
			}
		}
		System.out.println(count);
	}

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] d = new int[N];

		for(int i = 0; i < N; i++) {
			String line = sc.next();
			d[i] = Integer.parseInt(line);
		}

		int K = 0;
		int count = 0;
		int countLeft = 0;
		int countRight = N;
		Arrays.sort(d);

		for(int i = 0; i < N; i++) {
			countLeft++;
			countRight--;
			if(countLeft == countRight) {
				K = d[i];
				while(d[i] <= K && K < d[i+1]) {
					K++;
					count++;
				}
				break;
			}
		}
		System.out.println(count);
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] d = new int[N];

		for(int i = 0; i < N; i++) {
			String line = sc.next();
			d[i] = Integer.parseInt(line);
		}

		int K = 0;
		int count = 0;
		int countLeft = 0;
		int countRight = N;
		Arrays.sort(d);

		for(int i = 0; i < N; i++) {
			countLeft++;
			countRight--;
			if(countLeft == countRight) {
				K = d[i];
				while(d[i] <= K && K < d[i+1]) {
					K++;
					count++;
				}
				break;
			}
		}
		System.out.println(count);
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] d = new int[N];

		for(int i = 0; i < N; i++) {
			String line = sc.next();
			d[i] = Integer.parseInt(line);
		}

		int K = 0;
		int count = 0;
		int countLeft = 0;
		int countRight = N;
		Arrays.sort(d);

		for(int i = 0; i < N; i++) {
			countLeft++;
			countRight--;
			if(countLeft == countRight) {
				K = d[i];
				while(d[i] <= K && K < d[i+1]) {
					K++;
					count++;
				}
				break;
			}
		}
		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] d = new int[N]; d new int[N] N for(int i = 0; i < N; i++) {
			String line = sc.next();
			d[i] = Integer.parseInt(line);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			String line = sc.next();
			d[i] = Integer.parseInt(line);
		} {
			String line = sc.next();
			d[i] = Integer.parseInt(line);
		} String line = sc.next(); line sc.next() sc.next sc d[i] = Integer.parseInt(line) d[i] d i Integer.parseInt(line) Integer.parseInt Integer line int K = 0; K 0 int count = 0; count 0 int countLeft = 0; countLeft 0 int countRight = N; countRight N Arrays.sort(d) Arrays.sort Arrays d for(int i = 0; i < N; i++) {
			countLeft++;
			countRight--;
			if(countLeft == countRight) {
				K = d[i];
				while(d[i] <= K && K < d[i+1]) {
					K++;
					count++;
				}
				break;
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			countLeft++;
			countRight--;
			if(countLeft == countRight) {
				K = d[i];
				while(d[i] <= K && K < d[i+1]) {
					K++;
					count++;
				}
				break;
			}
		} {
			countLeft++;
			countRight--;
			if(countLeft == countRight) {
				K = d[i];
				while(d[i] <= K && K < d[i+1]) {
					K++;
					count++;
				}
				break;
			}
		} countLeft++ countLeft countRight-- countRight if(countLeft == countRight) {
				K = d[i];
				while(d[i] <= K && K < d[i+1]) {
					K++;
					count++;
				}
				break;
			} countLeft == countRight countLeft countRight {
				K = d[i];
				while(d[i] <= K && K < d[i+1]) {
					K++;
					count++;
				}
				break;
			} K = d[i] K d[i] d i while(d[i] <= K && K < d[i+1]) {
					K++;
					count++;
				} d[i] <= K && K < d[i+1] d[i] <= K d[i] d i K K < d[i+1] K d[i+1] d i+1 i 1 {
					K++;
					count++;
				} K++ K count++ count break; System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] d = new int[N];

		for(int i = 0; i < N; i++) {
			String line = sc.next();
			d[i] = Integer.parseInt(line);
		}

		int K = 0;
		int count = 0;
		int countLeft = 0;
		int countRight = N;
		Arrays.sort(d);

		for(int i = 0; i < N; i++) {
			countLeft++;
			countRight--;
			if(countLeft == countRight) {
				K = d[i];
				while(d[i] <= K && K < d[i+1]) {
					K++;
					count++;
				}
				break;
			}
		}
		System.out.println(count);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] d = new int[N];

		for(int i = 0; i < N; i++) {
			String line = sc.next();
			d[i] = Integer.parseInt(line);
		}

		int K = 0;
		int count = 0;
		int countLeft = 0;
		int countRight = N;
		Arrays.sort(d);

		for(int i = 0; i < N; i++) {
			countLeft++;
			countRight--;
			if(countLeft == countRight) {
				K = d[i];
				while(d[i] <= K && K < d[i+1]) {
					K++;
					count++;
				}
				break;
			}
		}
		System.out.println(count);
	}

} Main

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] d = new int[N];

		for(int i = 0; i < N; i++) {
			String line = sc.next();
			d[i] = Integer.parseInt(line);
		}

		int K = 0;
		int count = 0;
		int countLeft = 0;
		int countRight = N;
		Arrays.sort(d);

		for(int i = 0; i < N; i++) {
			countLeft++;
			countRight--;
			if(countLeft == countRight) {
				K = d[i];
				while(d[i] <= K && K < d[i+1]) {
					K++;
					count++;
				}
				break;
			}
		}
		System.out.println(count);
	}

}
