import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = std.nextInt();
        }
        
        int min = Arrays.stream(as).min().getAsInt();
        int max = Arrays.stream(as).max().getAsInt();
        System.out.println(max - min);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = std.nextInt();
        }
        
        int min = Arrays.stream(as).min().getAsInt();
        int max = Arrays.stream(as).max().getAsInt();
        System.out.println(max - min);
    }
} Main public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = std.nextInt();
        }
        
        int min = Arrays.stream(as).min().getAsInt();
        int max = Arrays.stream(as).max().getAsInt();
        System.out.println(max - min);
    } main {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = std.nextInt();
        }
        
        int min = Arrays.stream(as).min().getAsInt();
        int max = Arrays.stream(as).max().getAsInt();
        System.out.println(max - min);
    } Scanner std = new Scanner(System.in); std new Scanner(System.in) int n = std.nextInt(); n std.nextInt() std.nextInt std int[] as = new int[n]; as new int[n] n for (int i = 0; i < n; i++) {
            as[i] = std.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            as[i] = std.nextInt();
        } {
            as[i] = std.nextInt();
        } as[i] = std.nextInt() as[i] as i std.nextInt() std.nextInt std int min = Arrays.stream(as).min().getAsInt(); min Arrays.stream(as).min().getAsInt() Arrays.stream(as).min().getAsInt Arrays.stream(as).min() Arrays.stream(as).min Arrays.stream(as) Arrays.stream Arrays as int max = Arrays.stream(as).max().getAsInt(); max Arrays.stream(as).max().getAsInt() Arrays.stream(as).max().getAsInt Arrays.stream(as).max() Arrays.stream(as).max Arrays.stream(as) Arrays.stream Arrays as 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 std = new Scanner(System.in);
        int n = std.nextInt();
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = std.nextInt();
        }
        
        int min = Arrays.stream(as).min().getAsInt();
        int max = Arrays.stream(as).max().getAsInt();
        System.out.println(max - min);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = std.nextInt();
        }
        
        int min = Arrays.stream(as).min().getAsInt();
        int max = Arrays.stream(as).max().getAsInt();
        System.out.println(max - min);
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = std.nextInt();
        }
        
        int min = Arrays.stream(as).min().getAsInt();
        int max = Arrays.stream(as).max().getAsInt();
        System.out.println(max - min);
    }
}
