import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int k = sc.nextInt();
		int min = Integer.MAX_VALUE;
		int max = Integer.MIN_VALUE;
		for (int i=0; i<n; i++) {
			int temp = sc.nextInt();
			min = Math.min(min,temp);
			max = Math.max(max,temp);
		}
		System.out.println(max-min);
	}
}