import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] A = new int[n];

    for(int i = 0; i < n; i++)
      A[i] = scan.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.*; util.* java import java.io.*; io.* java public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] A = new int[n];

    for(int i = 0; i < n; i++)
      A[i] = scan.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 scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] A = new int[n];

    for(int i = 0; i < n; i++)
      A[i] = scan.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 scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] A = new int[n];

    for(int i = 0; i < n; i++)
      A[i] = scan.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 scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int[] A = new int[n]; A new int[n] n for(int i = 0; i < n; i++)
      A[i] = scan.nextInt(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i A[i] = scan.nextInt(); A[i] = scan.nextInt() A[i] A i scan.nextInt() scan.nextInt scan 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 scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] A = new int[n];

    for(int i = 0; i < n; i++)
      A[i] = scan.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 scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] A = new int[n];

    for(int i = 0; i < n; i++)
      A[i] = scan.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.*;
import java.io.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] A = new int[n];

    for(int i = 0; i < n; i++)
      A[i] = scan.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);
  }
}
