import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数字の数
		int N = sc.nextInt();
		int K = sc.nextInt();
		//振り分けた際のグループの個数
		int[] num = new int[N];
		for(int i = 0; i < N; i++) {
			num[i] = sc.nextInt();
		}
		Arrays.sort(num);
		int min = num[0];
		int max = num[num.length - 1];
		int ans = max - min;
		System.out.println(ans);
	}
}