import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
    	int N = scanner.nextInt();
		int diff = 0;
		
		//自動ソートしてくれるset
		Set<Integer> treeSet = new TreeSet<>();
    	
		for (int i = 0; i < N; i++) {
			treeSet.add(scanner.nextInt());
		}
		
		try {
			//treeSetをlistに格納
			//Integer[] list = new Integer[N];
			//treeSet.toArray(list);
			
			Integer[] list = treeSet.toArray(new Integer[N]);
			
			int min = list[0];
			int max = list[list.length - 1];
			
			//System.out.println("min : " + min);
			//System.out.println("max : " + max);
			
			diff = max - min;
			System.out.println(diff);
		
		} catch (NullPointerException e) {
			//System.err.println("エラー" + e.getMessage());
			System.out.println(diff);
		}
	}
} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
    	int N = scanner.nextInt();
		int diff = 0;
		
		//自動ソートしてくれるset
		Set<Integer> treeSet = new TreeSet<>();
    	
		for (int i = 0; i < N; i++) {
			treeSet.add(scanner.nextInt());
		}
		
		try {
			//treeSetをlistに格納
			//Integer[] list = new Integer[N];
			//treeSet.toArray(list);
			
			Integer[] list = treeSet.toArray(new Integer[N]);
			
			int min = list[0];
			int max = list[list.length - 1];
			
			//System.out.println("min : " + min);
			//System.out.println("max : " + max);
			
			diff = max - min;
			System.out.println(diff);
		
		} catch (NullPointerException e) {
			//System.err.println("エラー" + e.getMessage());
			System.out.println(diff);
		}
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
    	int N = scanner.nextInt();
		int diff = 0;
		
		//自動ソートしてくれるset
		Set<Integer> treeSet = new TreeSet<>();
    	
		for (int i = 0; i < N; i++) {
			treeSet.add(scanner.nextInt());
		}
		
		try {
			//treeSetをlistに格納
			//Integer[] list = new Integer[N];
			//treeSet.toArray(list);
			
			Integer[] list = treeSet.toArray(new Integer[N]);
			
			int min = list[0];
			int max = list[list.length - 1];
			
			//System.out.println("min : " + min);
			//System.out.println("max : " + max);
			
			diff = max - min;
			System.out.println(diff);
		
		} catch (NullPointerException e) {
			//System.err.println("エラー" + e.getMessage());
			System.out.println(diff);
		}
	} main {
		Scanner scanner = new Scanner(System.in);
    	int N = scanner.nextInt();
		int diff = 0;
		
		//自動ソートしてくれるset
		Set<Integer> treeSet = new TreeSet<>();
    	
		for (int i = 0; i < N; i++) {
			treeSet.add(scanner.nextInt());
		}
		
		try {
			//treeSetをlistに格納
			//Integer[] list = new Integer[N];
			//treeSet.toArray(list);
			
			Integer[] list = treeSet.toArray(new Integer[N]);
			
			int min = list[0];
			int max = list[list.length - 1];
			
			//System.out.println("min : " + min);
			//System.out.println("max : " + max);
			
			diff = max - min;
			System.out.println(diff);
		
		} catch (NullPointerException e) {
			//System.err.println("エラー" + e.getMessage());
			System.out.println(diff);
		}
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int diff = 0; diff 0 Set<Integer> treeSet = new TreeSet<>(); treeSet new TreeSet<>() for (int i = 0; i < N; i++) {
			treeSet.add(scanner.nextInt());
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			treeSet.add(scanner.nextInt());
		} {
			treeSet.add(scanner.nextInt());
		} treeSet.add(scanner.nextInt()) treeSet.add treeSet scanner.nextInt() scanner.nextInt scanner try {
			//treeSetをlistに格納
			//Integer[] list = new Integer[N];
			//treeSet.toArray(list);
			
			Integer[] list = treeSet.toArray(new Integer[N]);
			
			int min = list[0];
			int max = list[list.length - 1];
			
			//System.out.println("min : " + min);
			//System.out.println("max : " + max);
			
			diff = max - min;
			System.out.println(diff);
		
		} catch (NullPointerException e) {
			//System.err.println("エラー" + e.getMessage());
			System.out.println(diff);
		} catch (NullPointerException e) {
			//System.err.println("エラー" + e.getMessage());
			System.out.println(diff);
		} NullPointerException e {
			//System.err.println("エラー" + e.getMessage());
			System.out.println(diff);
		} System.out.println(diff) System.out.println System.out System System.out diff {
			//treeSetをlistに格納
			//Integer[] list = new Integer[N];
			//treeSet.toArray(list);
			
			Integer[] list = treeSet.toArray(new Integer[N]);
			
			int min = list[0];
			int max = list[list.length - 1];
			
			//System.out.println("min : " + min);
			//System.out.println("max : " + max);
			
			diff = max - min;
			System.out.println(diff);
		
		} Integer[] list = treeSet.toArray(new Integer[N]); list treeSet.toArray(new Integer[N]) treeSet.toArray treeSet new Integer[N] N int min = list[0]; min list[0] list 0 int max = list[list.length - 1]; max list[list.length - 1] list list.length - 1 list.length list list.length 1 diff = max - min diff max - min max min System.out.println(diff) System.out.println System.out System System.out diff String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
    	int N = scanner.nextInt();
		int diff = 0;
		
		//自動ソートしてくれるset
		Set<Integer> treeSet = new TreeSet<>();
    	
		for (int i = 0; i < N; i++) {
			treeSet.add(scanner.nextInt());
		}
		
		try {
			//treeSetをlistに格納
			//Integer[] list = new Integer[N];
			//treeSet.toArray(list);
			
			Integer[] list = treeSet.toArray(new Integer[N]);
			
			int min = list[0];
			int max = list[list.length - 1];
			
			//System.out.println("min : " + min);
			//System.out.println("max : " + max);
			
			diff = max - min;
			System.out.println(diff);
		
		} catch (NullPointerException e) {
			//System.err.println("エラー" + e.getMessage());
			System.out.println(diff);
		}
	}
} public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
    	int N = scanner.nextInt();
		int diff = 0;
		
		//自動ソートしてくれるset
		Set<Integer> treeSet = new TreeSet<>();
    	
		for (int i = 0; i < N; i++) {
			treeSet.add(scanner.nextInt());
		}
		
		try {
			//treeSetをlistに格納
			//Integer[] list = new Integer[N];
			//treeSet.toArray(list);
			
			Integer[] list = treeSet.toArray(new Integer[N]);
			
			int min = list[0];
			int max = list[list.length - 1];
			
			//System.out.println("min : " + min);
			//System.out.println("max : " + max);
			
			diff = max - min;
			System.out.println(diff);
		
		} catch (NullPointerException e) {
			//System.err.println("エラー" + e.getMessage());
			System.out.println(diff);
		}
	}
} Main
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
    	int N = scanner.nextInt();
		int diff = 0;
		
		//自動ソートしてくれるset
		Set<Integer> treeSet = new TreeSet<>();
    	
		for (int i = 0; i < N; i++) {
			treeSet.add(scanner.nextInt());
		}
		
		try {
			//treeSetをlistに格納
			//Integer[] list = new Integer[N];
			//treeSet.toArray(list);
			
			Integer[] list = treeSet.toArray(new Integer[N]);
			
			int min = list[0];
			int max = list[list.length - 1];
			
			//System.out.println("min : " + min);
			//System.out.println("max : " + max);
			
			diff = max - min;
			System.out.println(diff);
		
		} catch (NullPointerException e) {
			//System.err.println("エラー" + e.getMessage());
			System.out.println(diff);
		}
	}
}