import java.util.Scanner; class main{ public static void main(String args[]){ Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int K = scan.nextInt(); int max = 0; int min = 1000; for(int i = 0; i < N; i++){ int num = scan.nextInt(); max = Math.max(max, num); min = Math.min(min, num); } System.out.printf("%d\n", max - min); } }