import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        int max = 0;
        int min = 2147483647;
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }
        for(int j = 0; j < N; j++){
            max = Math.max(max, a[j]);
        }
        for(int k = 0; k < N; k++){
            min = Math.min(min, a[k]);
        }
        System.out.println(max-min);
    }
} import java.util.*; util.* java import java.lang.*; lang.* java public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        int max = 0;
        int min = 2147483647;
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }
        for(int j = 0; j < N; j++){
            max = Math.max(max, a[j]);
        }
        for(int k = 0; k < N; k++){
            min = Math.min(min, a[k]);
        }
        System.out.println(max-min);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        int max = 0;
        int min = 2147483647;
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }
        for(int j = 0; j < N; j++){
            max = Math.max(max, a[j]);
        }
        for(int k = 0; k < N; k++){
            min = Math.min(min, a[k]);
        }
        System.out.println(max-min);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        int max = 0;
        int min = 2147483647;
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }
        for(int j = 0; j < N; j++){
            max = Math.max(max, a[j]);
        }
        for(int k = 0; k < N; k++){
            min = Math.min(min, a[k]);
        }
        System.out.println(max-min);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] a = new int[N]; a new int[N] N int max = 0; max 0 int min = 2147483647; min 2147483647 for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            a[i] = sc.nextInt();
        } {
            a[i] = sc.nextInt();
        } a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc for(int j = 0; j < N; j++){
            max = Math.max(max, a[j]);
        } int j = 0; int j = 0; j 0 j < N j N j++ j++ j {
            max = Math.max(max, a[j]);
        } {
            max = Math.max(max, a[j]);
        } max = Math.max(max, a[j]) max Math.max(max, a[j]) Math.max Math max a[j] a j for(int k = 0; k < N; k++){
            min = Math.min(min, a[k]);
        } int k = 0; int k = 0; k 0 k < N k N k++ k++ k {
            min = Math.min(min, a[k]);
        } {
            min = Math.min(min, a[k]);
        } min = Math.min(min, a[k]) min Math.min(min, a[k]) Math.min Math min a[k] a k System.out.println(max-min) System.out.println System.out System System.out max-min max min String[] args args public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        int max = 0;
        int min = 2147483647;
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }
        for(int j = 0; j < N; j++){
            max = Math.max(max, a[j]);
        }
        for(int k = 0; k < N; k++){
            min = Math.min(min, a[k]);
        }
        System.out.println(max-min);
    }
} public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        int max = 0;
        int min = 2147483647;
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }
        for(int j = 0; j < N; j++){
            max = Math.max(max, a[j]);
        }
        for(int k = 0; k < N; k++){
            min = Math.min(min, a[k]);
        }
        System.out.println(max-min);
    }
} Main
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        int max = 0;
        int min = 2147483647;
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }
        for(int j = 0; j < N; j++){
            max = Math.max(max, a[j]);
        }
        for(int k = 0; k < N; k++){
            min = Math.min(min, a[k]);
        }
        System.out.println(max-min);
    }
}