import java.io.*; import java.util.stream.*; // 処理 class Process { private PrintWriter printWriter; private int[] n; Process(PrintWriter printWriter, int[] n) { this.printWriter = printWriter; this.n = n; } // 結果を出力 void printResult() throws IOException { printWriter.println(IntStream.of(n).max().getAsInt() - IntStream.of(n).min().getAsInt()); } } public class Main { public static void main(String[] args) throws IOException { var bufferedReader = new BufferedReader(new InputStreamReader(System.in)); var printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); // 入力 int N = Integer.parseInt(bufferedReader.readLine().trim()); int K = Integer.parseInt(bufferedReader.readLine().trim()); int[] n = new int[N]; for(int i = 0; i < N; i++) { n[i] = Integer.parseInt(bufferedReader.readLine().trim()); } // Process クラスで処理を行う var process = new Process(printWriter, n); process.printResult(); // 各ストリームを閉じる // 出力ストリームを閉じるときに標準出力に文字を出力する bufferedReader.close(); printWriter.close(); } }