import java.util.Scanner;
import java.util.TreeSet;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    TreeSet<Integer> set = new TreeSet<Integer>();
    int n = sc.nextInt();
    for(int a=0;a<n;a++){
      set.add(sc.nextInt());
    }
    System.out.println(set.last()-set.first());
  }
}