import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/*Atcoder用
 * 		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		int a = Integer.parseInt(tmp[0]);
		int b = Integer.parseInt(tmp[1]);
		int c = Integer.parseInt(tmp[2]);


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String get = br.readLine();
		char[] s = get.toCharArray();
		for(char c:s)System.out.println(c);

		List<Integer> ls = new ArrayList<Integer>();
		String[] tmp = br.readLine().split(" ");
		for (int n = 0; n < N; n++) {
			ls.add(Integer.parseInt(tmp[n]));
		}
 */

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tmp = br.readLine();
		int a = Integer.parseInt(tmp);

		List<Integer> ls = new ArrayList<Integer>();
		String[] tmp2 = br.readLine().split(" ");
		for (int n = 0; n < tmp2.length; n++) {
			ls.add(Integer.parseInt(tmp2[n]));
		}
		int i = Collections.max(ls) - Collections.min(ls);

		System.out.println(i);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List java.util public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tmp = br.readLine();
		int a = Integer.parseInt(tmp);

		List<Integer> ls = new ArrayList<Integer>();
		String[] tmp2 = br.readLine().split(" ");
		for (int n = 0; n < tmp2.length; n++) {
			ls.add(Integer.parseInt(tmp2[n]));
		}
		int i = Collections.max(ls) - Collections.min(ls);

		System.out.println(i);
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tmp = br.readLine();
		int a = Integer.parseInt(tmp);

		List<Integer> ls = new ArrayList<Integer>();
		String[] tmp2 = br.readLine().split(" ");
		for (int n = 0; n < tmp2.length; n++) {
			ls.add(Integer.parseInt(tmp2[n]));
		}
		int i = Collections.max(ls) - Collections.min(ls);

		System.out.println(i);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tmp = br.readLine();
		int a = Integer.parseInt(tmp);

		List<Integer> ls = new ArrayList<Integer>();
		String[] tmp2 = br.readLine().split(" ");
		for (int n = 0; n < tmp2.length; n++) {
			ls.add(Integer.parseInt(tmp2[n]));
		}
		int i = Collections.max(ls) - Collections.min(ls);

		System.out.println(i);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String tmp = br.readLine(); tmp br.readLine() br.readLine br int a = Integer.parseInt(tmp); a Integer.parseInt(tmp) Integer.parseInt Integer tmp List<Integer> ls = new ArrayList<Integer>(); ls new ArrayList<Integer>() String[] tmp2 = br.readLine().split(" "); tmp2 br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for (int n = 0; n < tmp2.length; n++) {
			ls.add(Integer.parseInt(tmp2[n]));
		} int n = 0; int n = 0; n 0 n < tmp2.length n tmp2.length tmp2 tmp2.length n++ n++ n {
			ls.add(Integer.parseInt(tmp2[n]));
		} {
			ls.add(Integer.parseInt(tmp2[n]));
		} ls.add(Integer.parseInt(tmp2[n])) ls.add ls Integer.parseInt(tmp2[n]) Integer.parseInt Integer tmp2[n] tmp2 n int i = Collections.max(ls) - Collections.min(ls); i Collections.max(ls) - Collections.min(ls) Collections.max(ls) Collections.max Collections ls Collections.min(ls) Collections.min Collections ls System.out.println(i) System.out.println System.out System System.out i String[] args args public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tmp = br.readLine();
		int a = Integer.parseInt(tmp);

		List<Integer> ls = new ArrayList<Integer>();
		String[] tmp2 = br.readLine().split(" ");
		for (int n = 0; n < tmp2.length; n++) {
			ls.add(Integer.parseInt(tmp2[n]));
		}
		int i = Collections.max(ls) - Collections.min(ls);

		System.out.println(i);
	}
} public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tmp = br.readLine();
		int a = Integer.parseInt(tmp);

		List<Integer> ls = new ArrayList<Integer>();
		String[] tmp2 = br.readLine().split(" ");
		for (int n = 0; n < tmp2.length; n++) {
			ls.add(Integer.parseInt(tmp2[n]));
		}
		int i = Collections.max(ls) - Collections.min(ls);

		System.out.println(i);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/*Atcoder用
 * 		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		int a = Integer.parseInt(tmp[0]);
		int b = Integer.parseInt(tmp[1]);
		int c = Integer.parseInt(tmp[2]);


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String get = br.readLine();
		char[] s = get.toCharArray();
		for(char c:s)System.out.println(c);

		List<Integer> ls = new ArrayList<Integer>();
		String[] tmp = br.readLine().split(" ");
		for (int n = 0; n < N; n++) {
			ls.add(Integer.parseInt(tmp[n]));
		}
 */

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tmp = br.readLine();
		int a = Integer.parseInt(tmp);

		List<Integer> ls = new ArrayList<Integer>();
		String[] tmp2 = br.readLine().split(" ");
		for (int n = 0; n < tmp2.length; n++) {
			ls.add(Integer.parseInt(tmp2[n]));
		}
		int i = Collections.max(ls) - Collections.min(ls);

		System.out.println(i);
	}
}