n=STDIN.gets.to_i
k=STDIN.gets.to_i
as=[]
n.times do |i|
	a=STDIN.gets.to_i
	as<<a
end
puts as.max-as.min