import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int A[] = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
        }

        int min = A[0];
        int max = A[0];
        for (int i = 1; i < N; i++) {
            min = Math.min(min, A[i]);
            max = Math.max(max, A[i]);
        }
        System.out.println(max - min);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int A[] = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
        }

        int min = A[0];
        int max = A[0];
        for (int i = 1; i < N; i++) {
            min = Math.min(min, A[i]);
            max = Math.max(max, A[i]);
        }
        System.out.println(max - min);
    }
} Main public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int A[] = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
        }

        int min = A[0];
        int max = A[0];
        for (int i = 1; i < N; i++) {
            min = Math.min(min, A[i]);
            max = Math.max(max, A[i]);
        }
        System.out.println(max - min);
    } main {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int A[] = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
        }

        int min = A[0];
        int max = A[0];
        for (int i = 1; i < N; i++) {
            min = Math.min(min, A[i]);
            max = Math.max(max, A[i]);
        }
        System.out.println(max - min);
    } Scanner cin = new Scanner(System.in); cin new Scanner(System.in) int N = cin.nextInt(); N cin.nextInt() cin.nextInt cin int A[] = new int[N]; A new int[N] N for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            A[i] = cin.nextInt();
        } {
            A[i] = cin.nextInt();
        } A[i] = cin.nextInt() A[i] A i cin.nextInt() cin.nextInt cin int min = A[0]; min A[0] A 0 int max = A[0]; max A[0] A 0 for (int i = 1; i < N; i++) {
            min = Math.min(min, A[i]);
            max = Math.max(max, A[i]);
        } int i = 1; int i = 1; i 1 i < N i N i++ i++ i {
            min = Math.min(min, A[i]);
            max = Math.max(max, A[i]);
        } {
            min = Math.min(min, A[i]);
            max = Math.max(max, A[i]);
        } min = Math.min(min, A[i]) min Math.min(min, A[i]) Math.min Math min A[i] A i max = Math.max(max, A[i]) max Math.max(max, A[i]) Math.max Math max A[i] A i 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 cin = new Scanner(System.in);
        int N = cin.nextInt();
        int A[] = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
        }

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

        int min = A[0];
        int max = A[0];
        for (int i = 1; i < N; i++) {
            min = Math.min(min, A[i]);
            max = Math.max(max, A[i]);
        }
        System.out.println(max - min);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int A[] = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
        }

        int min = A[0];
        int max = A[0];
        for (int i = 1; i < N; i++) {
            min = Math.min(min, A[i]);
            max = Math.max(max, A[i]);
        }
        System.out.println(max - min);
    }
}
