import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] st = new int[n];
            for(int i = 0; i < n; i++){
              st[i] = sc.nextInt();
          }
          Arrays.sort(st);
          int a = st[0];
          int b = st[n-1];
          System.out.println(Math.abs(a-b));
}
} import java.util.*; util.* java public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] st = new int[n];
            for(int i = 0; i < n; i++){
              st[i] = sc.nextInt();
          }
          Arrays.sort(st);
          int a = st[0];
          int b = st[n-1];
          System.out.println(Math.abs(a-b));
}
} Main public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] st = new int[n];
            for(int i = 0; i < n; i++){
              st[i] = sc.nextInt();
          }
          Arrays.sort(st);
          int a = st[0];
          int b = st[n-1];
          System.out.println(Math.abs(a-b));
} main {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] st = new int[n];
            for(int i = 0; i < n; i++){
              st[i] = sc.nextInt();
          }
          Arrays.sort(st);
          int a = st[0];
          int b = st[n-1];
          System.out.println(Math.abs(a-b));
} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] st = new int[n]; st new int[n] n for(int i = 0; i < n; i++){
              st[i] = sc.nextInt();
          } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
              st[i] = sc.nextInt();
          } {
              st[i] = sc.nextInt();
          } st[i] = sc.nextInt() st[i] st i sc.nextInt() sc.nextInt sc Arrays.sort(st) Arrays.sort Arrays st int a = st[0]; a st[0] st 0 int b = st[n-1]; b st[n-1] st n-1 n 1 System.out.println(Math.abs(a-b)) System.out.println System.out System System.out Math.abs(a-b) Math.abs Math a-b a b String[] args args public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] st = new int[n];
            for(int i = 0; i < n; i++){
              st[i] = sc.nextInt();
          }
          Arrays.sort(st);
          int a = st[0];
          int b = st[n-1];
          System.out.println(Math.abs(a-b));
}
} public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] st = new int[n];
            for(int i = 0; i < n; i++){
              st[i] = sc.nextInt();
          }
          Arrays.sort(st);
          int a = st[0];
          int b = st[n-1];
          System.out.println(Math.abs(a-b));
}
} Main
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] st = new int[n];
            for(int i = 0; i < n; i++){
              st[i] = sc.nextInt();
          }
          Arrays.sort(st);
          int a = st[0];
          int b = st[n-1];
          System.out.println(Math.abs(a-b));
}
}