import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; class Main{ 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[] arr = new int[n]; for(int i = 0; i < n; i++){ arr[i] = Integer.parseInt(br.readLine()); } Arrays.sort(arr); System.out.println((arr[n-1] - arr[0])); } }