import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int[] ds = new int[N];
			for(int i = 0; i < N; i++) { ds[i] = sc.nextInt(); }
			Arrays.sort(ds);
			//System.out.println(Arrays.toString(ds));
			
			int answer_min = 0, answer_max = -1;
			
			int prev = -1;
			for(int i = 0; i < N; i++) {
				final int curr = ds[i];
				if(prev == curr) { continue; }
				prev = curr;
				
				final int ABC = i;
				final int ARC = N - ABC;
				
				//System.out.println(ABC + " " + ARC);
				
				if(ABC == ARC) { answer_max = curr; }
				if(ABC < ARC && curr > answer_min) { answer_min = curr; }
			}
			
			//System.out.println(answer_max + " " + answer_min);
			
			if(answer_max < 0) {
				System.out.println(0);
			}else {
				System.out.println(answer_max - answer_min);
			}
			

		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.Closeable; Closeable java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.HashSet; HashSet java.util import java.util.LinkedList; LinkedList java.util import java.util.Map.Entry; Entry java.util.Map import java.util.PriorityQueue; PriorityQueue java.util import java.util.StringTokenizer; StringTokenizer java.util import java.util.TreeSet; TreeSet java.util public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int[] ds = new int[N];
			for(int i = 0; i < N; i++) { ds[i] = sc.nextInt(); }
			Arrays.sort(ds);
			//System.out.println(Arrays.toString(ds));
			
			int answer_min = 0, answer_max = -1;
			
			int prev = -1;
			for(int i = 0; i < N; i++) {
				final int curr = ds[i];
				if(prev == curr) { continue; }
				prev = curr;
				
				final int ABC = i;
				final int ARC = N - ABC;
				
				//System.out.println(ABC + " " + ARC);
				
				if(ABC == ARC) { answer_max = curr; }
				if(ABC < ARC && curr > answer_min) { answer_min = curr; }
			}
			
			//System.out.println(answer_max + " " + answer_min);
			
			if(answer_max < 0) {
				System.out.println(0);
			}else {
				System.out.println(answer_max - answer_min);
			}
			

		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
} Main public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int[] ds = new int[N];
			for(int i = 0; i < N; i++) { ds[i] = sc.nextInt(); }
			Arrays.sort(ds);
			//System.out.println(Arrays.toString(ds));
			
			int answer_min = 0, answer_max = -1;
			
			int prev = -1;
			for(int i = 0; i < N; i++) {
				final int curr = ds[i];
				if(prev == curr) { continue; }
				prev = curr;
				
				final int ABC = i;
				final int ARC = N - ABC;
				
				//System.out.println(ABC + " " + ARC);
				
				if(ABC == ARC) { answer_max = curr; }
				if(ABC < ARC && curr > answer_min) { answer_min = curr; }
			}
			
			//System.out.println(answer_max + " " + answer_min);
			
			if(answer_max < 0) {
				System.out.println(0);
			}else {
				System.out.println(answer_max - answer_min);
			}
			

		}
	} main {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int[] ds = new int[N];
			for(int i = 0; i < N; i++) { ds[i] = sc.nextInt(); }
			Arrays.sort(ds);
			//System.out.println(Arrays.toString(ds));
			
			int answer_min = 0, answer_max = -1;
			
			int prev = -1;
			for(int i = 0; i < N; i++) {
				final int curr = ds[i];
				if(prev == curr) { continue; }
				prev = curr;
				
				final int ABC = i;
				final int ARC = N - ABC;
				
				//System.out.println(ABC + " " + ARC);
				
				if(ABC == ARC) { answer_max = curr; }
				if(ABC < ARC && curr > answer_min) { answer_min = curr; }
			}
			
			//System.out.println(answer_max + " " + answer_min);
			
			if(answer_max < 0) {
				System.out.println(0);
			}else {
				System.out.println(answer_max - answer_min);
			}
			

		}
	} try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int[] ds = new int[N];
			for(int i = 0; i < N; i++) { ds[i] = sc.nextInt(); }
			Arrays.sort(ds);
			//System.out.println(Arrays.toString(ds));
			
			int answer_min = 0, answer_max = -1;
			
			int prev = -1;
			for(int i = 0; i < N; i++) {
				final int curr = ds[i];
				if(prev == curr) { continue; }
				prev = curr;
				
				final int ABC = i;
				final int ARC = N - ABC;
				
				//System.out.println(ABC + " " + ARC);
				
				if(ABC == ARC) { answer_max = curr; }
				if(ABC < ARC && curr > answer_min) { answer_min = curr; }
			}
			
			//System.out.println(answer_max + " " + answer_min);
			
			if(answer_max < 0) {
				System.out.println(0);
			}else {
				System.out.println(answer_max - answer_min);
			}
			

		} {
			final int N = sc.nextInt();
			
			int[] ds = new int[N];
			for(int i = 0; i < N; i++) { ds[i] = sc.nextInt(); }
			Arrays.sort(ds);
			//System.out.println(Arrays.toString(ds));
			
			int answer_min = 0, answer_max = -1;
			
			int prev = -1;
			for(int i = 0; i < N; i++) {
				final int curr = ds[i];
				if(prev == curr) { continue; }
				prev = curr;
				
				final int ABC = i;
				final int ARC = N - ABC;
				
				//System.out.println(ABC + " " + ARC);
				
				if(ABC == ARC) { answer_max = curr; }
				if(ABC < ARC && curr > answer_min) { answer_min = curr; }
			}
			
			//System.out.println(answer_max + " " + answer_min);
			
			if(answer_max < 0) {
				System.out.println(0);
			}else {
				System.out.println(answer_max - answer_min);
			}
			

		} final Scanner sc = new Scanner(System.in) final Scanner sc = new Scanner(System.in) new Scanner(System.in) final int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] ds = new int[N]; ds new int[N] N for(int i = 0; i < N; i++) { ds[i] = sc.nextInt(); } int i = 0; int i = 0; i 0 i < N i N i++ i++ i { ds[i] = sc.nextInt(); } { ds[i] = sc.nextInt(); } ds[i] = sc.nextInt() ds[i] ds i sc.nextInt() sc.nextInt sc Arrays.sort(ds) Arrays.sort Arrays ds int answer_min = 0 answer_min 0 answer_max = -1; answer_max -1 1 int prev = -1; prev -1 1 for(int i = 0; i < N; i++) {
				final int curr = ds[i];
				if(prev == curr) { continue; }
				prev = curr;
				
				final int ABC = i;
				final int ARC = N - ABC;
				
				//System.out.println(ABC + " " + ARC);
				
				if(ABC == ARC) { answer_max = curr; }
				if(ABC < ARC && curr > answer_min) { answer_min = curr; }
			} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
				final int curr = ds[i];
				if(prev == curr) { continue; }
				prev = curr;
				
				final int ABC = i;
				final int ARC = N - ABC;
				
				//System.out.println(ABC + " " + ARC);
				
				if(ABC == ARC) { answer_max = curr; }
				if(ABC < ARC && curr > answer_min) { answer_min = curr; }
			} {
				final int curr = ds[i];
				if(prev == curr) { continue; }
				prev = curr;
				
				final int ABC = i;
				final int ARC = N - ABC;
				
				//System.out.println(ABC + " " + ARC);
				
				if(ABC == ARC) { answer_max = curr; }
				if(ABC < ARC && curr > answer_min) { answer_min = curr; }
			} final int curr = ds[i]; curr ds[i] ds i if(prev == curr) { continue; } prev == curr prev curr { continue; } continue; prev = curr prev curr final int ABC = i; ABC i final int ARC = N - ABC; ARC N - ABC N ABC if(ABC == ARC) { answer_max = curr; } ABC == ARC ABC ARC { answer_max = curr; } answer_max = curr answer_max curr if(ABC < ARC && curr > answer_min) { answer_min = curr; } ABC < ARC && curr > answer_min ABC < ARC ABC ARC curr > answer_min curr answer_min { answer_min = curr; } answer_min = curr answer_min curr if(answer_max < 0) {
				System.out.println(0);
			}else {
				System.out.println(answer_max - answer_min);
			} answer_max < 0 answer_max 0 {
				System.out.println(0);
			} System.out.println(0) System.out.println System.out System System.out 0 {
				System.out.println(answer_max - answer_min);
			} System.out.println(answer_max - answer_min) System.out.println System.out System System.out answer_max - answer_min answer_max answer_min String[] args args public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	} Scanner private BufferedReader br; br private StringTokenizer tok; tok public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		} Scanner {
			br = new BufferedReader(new InputStreamReader(is));
		} br = new BufferedReader(new InputStreamReader(is)) br new BufferedReader(new InputStreamReader(is)) InputStream is is private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		} getLine {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		} while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			} !hasNext() hasNext() hasNext {
				tok = new StringTokenizer(br.readLine());
			} tok = new StringTokenizer(br.readLine()) tok new StringTokenizer(br.readLine()) private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		} hasNext {
			return tok != null && tok.hasMoreTokens();
		} return tok != null && tok.hasMoreTokens(); tok != null && tok.hasMoreTokens() tok != null tok null tok.hasMoreTokens() tok.hasMoreTokens tok public String next() throws IOException {
			getLine();
			return tok.nextToken();
		} next {
			getLine();
			return tok.nextToken();
		} getLine() getLine return tok.nextToken(); tok.nextToken() tok.nextToken tok public int nextInt() throws IOException {
			return Integer.parseInt(next());
		} nextInt {
			return Integer.parseInt(next());
		} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public long nextLong() throws IOException {
			return Long.parseLong(next());
		} nextLong {
			return Long.parseLong(next());
		} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		} nextDouble {
			return Double.parseDouble(next());
		} return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		} nextIntArray {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		} final int[] ret = new int[n]; ret new int[n] n for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				ret[i] = this.nextInt();
			} {
				ret[i] = this.nextInt();
			} ret[i] = this.nextInt() ret[i] ret i this.nextInt() this.nextInt this return ret; ret int n n public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		} nextLongArray {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		} final long[] ret = new long[n]; ret new long[n] n for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				ret[i] = this.nextLong();
			} {
				ret[i] = this.nextLong();
			} ret[i] = this.nextLong() ret[i] ret i this.nextLong() this.nextLong this return ret; ret int n n public void close() throws IOException {
			br.close();
		} close {
			br.close();
		} br.close() br.close br Closeable public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int[] ds = new int[N];
			for(int i = 0; i < N; i++) { ds[i] = sc.nextInt(); }
			Arrays.sort(ds);
			//System.out.println(Arrays.toString(ds));
			
			int answer_min = 0, answer_max = -1;
			
			int prev = -1;
			for(int i = 0; i < N; i++) {
				final int curr = ds[i];
				if(prev == curr) { continue; }
				prev = curr;
				
				final int ABC = i;
				final int ARC = N - ABC;
				
				//System.out.println(ABC + " " + ARC);
				
				if(ABC == ARC) { answer_max = curr; }
				if(ABC < ARC && curr > answer_min) { answer_min = curr; }
			}
			
			//System.out.println(answer_max + " " + answer_min);
			
			if(answer_max < 0) {
				System.out.println(0);
			}else {
				System.out.println(answer_max - answer_min);
			}
			

		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
} public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int[] ds = new int[N];
			for(int i = 0; i < N; i++) { ds[i] = sc.nextInt(); }
			Arrays.sort(ds);
			//System.out.println(Arrays.toString(ds));
			
			int answer_min = 0, answer_max = -1;
			
			int prev = -1;
			for(int i = 0; i < N; i++) {
				final int curr = ds[i];
				if(prev == curr) { continue; }
				prev = curr;
				
				final int ABC = i;
				final int ARC = N - ABC;
				
				//System.out.println(ABC + " " + ARC);
				
				if(ABC == ARC) { answer_max = curr; }
				if(ABC < ARC && curr > answer_min) { answer_min = curr; }
			}
			
			//System.out.println(answer_max + " " + answer_min);
			
			if(answer_max < 0) {
				System.out.println(0);
			}else {
				System.out.println(answer_max - answer_min);
			}
			

		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
} Main
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int[] ds = new int[N];
			for(int i = 0; i < N; i++) { ds[i] = sc.nextInt(); }
			Arrays.sort(ds);
			//System.out.println(Arrays.toString(ds));
			
			int answer_min = 0, answer_max = -1;
			
			int prev = -1;
			for(int i = 0; i < N; i++) {
				final int curr = ds[i];
				if(prev == curr) { continue; }
				prev = curr;
				
				final int ABC = i;
				final int ARC = N - ABC;
				
				//System.out.println(ABC + " " + ARC);
				
				if(ABC == ARC) { answer_max = curr; }
				if(ABC < ARC && curr > answer_min) { answer_min = curr; }
			}
			
			//System.out.println(answer_max + " " + answer_min);
			
			if(answer_max < 0) {
				System.out.println(0);
			}else {
				System.out.println(answer_max - answer_min);
			}
			

		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}