n = gets.to_i
k = gets.to_i
a = n.times.map{gets.to_i}

p a.max - a.min