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

public class Main {

    public static void main(String[] args) throws Exception {
	    String[] inputs = Io.read();

        int[] a = parse(inputs[1]);

        int min = Arrays.stream(a).min().getAsInt();
        int max = Arrays.stream(a).max().getAsInt();

        Io.write(max - min);
    }

    private static int[] parse(String line) {
        String[] split = line.split(" ");
        int[] parsed = new int[split.length];

        for (int i = 0; i < split.length; i++) {
            parsed[i] = Integer.parseInt(split[i]);
        }
        return parsed;
    }
}

class Io {

    public static String[] read() throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        List<String> inputs = new ArrayList<>();
        String line;
        while ((line = br.readLine()) != null) {
            if (line.equals(""))
                break;

            inputs.add(line);
        }
        br.close();
        return inputs.toArray(new String[0]);
    }

    public static void write(int answer)
    {
        System.out.println(answer);
    }
} 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.Arrays; Arrays java.util import java.util.List; List java.util public class Main {

    public static void main(String[] args) throws Exception {
	    String[] inputs = Io.read();

        int[] a = parse(inputs[1]);

        int min = Arrays.stream(a).min().getAsInt();
        int max = Arrays.stream(a).max().getAsInt();

        Io.write(max - min);
    }

    private static int[] parse(String line) {
        String[] split = line.split(" ");
        int[] parsed = new int[split.length];

        for (int i = 0; i < split.length; i++) {
            parsed[i] = Integer.parseInt(split[i]);
        }
        return parsed;
    }
} Main public static void main(String[] args) throws Exception {
	    String[] inputs = Io.read();

        int[] a = parse(inputs[1]);

        int min = Arrays.stream(a).min().getAsInt();
        int max = Arrays.stream(a).max().getAsInt();

        Io.write(max - min);
    } main {
	    String[] inputs = Io.read();

        int[] a = parse(inputs[1]);

        int min = Arrays.stream(a).min().getAsInt();
        int max = Arrays.stream(a).max().getAsInt();

        Io.write(max - min);
    } String[] inputs = Io.read(); inputs Io.read() Io.read Io int[] a = parse(inputs[1]); a parse(inputs[1]) parse inputs[1] inputs 1 int min = Arrays.stream(a).min().getAsInt(); min Arrays.stream(a).min().getAsInt() Arrays.stream(a).min().getAsInt Arrays.stream(a).min() Arrays.stream(a).min Arrays.stream(a) Arrays.stream Arrays a int max = Arrays.stream(a).max().getAsInt(); max Arrays.stream(a).max().getAsInt() Arrays.stream(a).max().getAsInt Arrays.stream(a).max() Arrays.stream(a).max Arrays.stream(a) Arrays.stream Arrays a Io.write(max - min) Io.write Io max - min max min String[] args args private static int[] parse(String line) {
        String[] split = line.split(" ");
        int[] parsed = new int[split.length];

        for (int i = 0; i < split.length; i++) {
            parsed[i] = Integer.parseInt(split[i]);
        }
        return parsed;
    } parse {
        String[] split = line.split(" ");
        int[] parsed = new int[split.length];

        for (int i = 0; i < split.length; i++) {
            parsed[i] = Integer.parseInt(split[i]);
        }
        return parsed;
    } String[] split = line.split(" "); split line.split(" ") line.split line " " int[] parsed = new int[split.length]; parsed new int[split.length] split.length split split.length for (int i = 0; i < split.length; i++) {
            parsed[i] = Integer.parseInt(split[i]);
        } int i = 0; int i = 0; i 0 i < split.length i split.length split split.length i++ i++ i {
            parsed[i] = Integer.parseInt(split[i]);
        } {
            parsed[i] = Integer.parseInt(split[i]);
        } parsed[i] = Integer.parseInt(split[i]) parsed[i] parsed i Integer.parseInt(split[i]) Integer.parseInt Integer split[i] split i return parsed; parsed String line line class Io {

    public static String[] read() throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        List<String> inputs = new ArrayList<>();
        String line;
        while ((line = br.readLine()) != null) {
            if (line.equals(""))
                break;

            inputs.add(line);
        }
        br.close();
        return inputs.toArray(new String[0]);
    }

    public static void write(int answer)
    {
        System.out.println(answer);
    }
} Io public static String[] read() throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        List<String> inputs = new ArrayList<>();
        String line;
        while ((line = br.readLine()) != null) {
            if (line.equals(""))
                break;

            inputs.add(line);
        }
        br.close();
        return inputs.toArray(new String[0]);
    } read {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        List<String> inputs = new ArrayList<>();
        String line;
        while ((line = br.readLine()) != null) {
            if (line.equals(""))
                break;

            inputs.add(line);
        }
        br.close();
        return inputs.toArray(new String[0]);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) List<String> inputs = new ArrayList<>(); inputs new ArrayList<>() String line; line while ((line = br.readLine()) != null) {
            if (line.equals(""))
                break;

            inputs.add(line);
        } (line = br.readLine()) != null (line = br.readLine()) line br.readLine() br.readLine br null {
            if (line.equals(""))
                break;

            inputs.add(line);
        } if (line.equals(""))
                break; line.equals("") line.equals line "" break; inputs.add(line) inputs.add inputs line br.close() br.close br return inputs.toArray(new String[0]); inputs.toArray(new String[0]) inputs.toArray inputs new String[0] 0 public static void write(int answer)
    {
        System.out.println(answer);
    } write {
        System.out.println(answer);
    } System.out.println(answer) System.out.println System.out System System.out answer int answer answer public class Main {

    public static void main(String[] args) throws Exception {
	    String[] inputs = Io.read();

        int[] a = parse(inputs[1]);

        int min = Arrays.stream(a).min().getAsInt();
        int max = Arrays.stream(a).max().getAsInt();

        Io.write(max - min);
    }

    private static int[] parse(String line) {
        String[] split = line.split(" ");
        int[] parsed = new int[split.length];

        for (int i = 0; i < split.length; i++) {
            parsed[i] = Integer.parseInt(split[i]);
        }
        return parsed;
    }
} public class Main {

    public static void main(String[] args) throws Exception {
	    String[] inputs = Io.read();

        int[] a = parse(inputs[1]);

        int min = Arrays.stream(a).min().getAsInt();
        int max = Arrays.stream(a).max().getAsInt();

        Io.write(max - min);
    }

    private static int[] parse(String line) {
        String[] split = line.split(" ");
        int[] parsed = new int[split.length];

        for (int i = 0; i < split.length; i++) {
            parsed[i] = Integer.parseInt(split[i]);
        }
        return parsed;
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {
	    String[] inputs = Io.read();

        int[] a = parse(inputs[1]);

        int min = Arrays.stream(a).min().getAsInt();
        int max = Arrays.stream(a).max().getAsInt();

        Io.write(max - min);
    }

    private static int[] parse(String line) {
        String[] split = line.split(" ");
        int[] parsed = new int[split.length];

        for (int i = 0; i < split.length; i++) {
            parsed[i] = Integer.parseInt(split[i]);
        }
        return parsed;
    }
}

class Io {

    public static String[] read() throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        List<String> inputs = new ArrayList<>();
        String line;
        while ((line = br.readLine()) != null) {
            if (line.equals(""))
                break;

            inputs.add(line);
        }
        br.close();
        return inputs.toArray(new String[0]);
    }

    public static void write(int answer)
    {
        System.out.println(answer);
    }
}