import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); int k = in.nextInt(); int min = in.nextInt(); int max = in.nextInt(); if (max < min) { int t = max; max = min; min = t; } for (int i = 0; i < N - 2; i++) { int val = in.nextInt(); if (max < val) max = val; if (min > val) min = val; } System.out.println(max - min); } }