n=gets.to_i
g=gets.to_i
a=n.times.map{gets.to_i}
puts a.max-a.min