import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { BufferedReader buff = new BufferedReader(new InputStreamReader(System.in)); try{ int N = Integer.parseInt(buff.readLine()); int K = Integer.parseInt(buff.readLine()); int[] box = new int[N]; for(int i = 0; i < N; ++i){ box[i] = Integer.parseInt(buff.readLine()); for(int j = 0; j < i; ++j){ if(box[i] < box[j]){ int w = box[i]; box[i] = box[j]; box[j] = w; } } } int posiMin = 0, posiMax = N -1; int max = box[posiMax], min = box[posiMin]; int ans = max - min; System.out.println(ans); } catch (NumberFormatException e) { } catch (IOException e) { } } }