n = gets.to_i k = gets.to_i m = n.times.map {gets.to_i}.sort puts m.last - m.first