import java.io.*; import java.util.*; import java.math.*; class Main21 { public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int k = Integer.parseInt(br.readLine()); int[] nums = new int[n]; int max = 0, min = 1001; for (int i = 0; i < n; i++) { nums[i] = Integer.parseInt(br.readLine()); max = Math.max(max, nums[i]); min = Math.min(min, nums[i]); } System.out.println(max - min); } }