n = gets.to_i k = gets.to_i ns = [] n.times do ns << gets.to_i end ns.sort! puts ns.last - ns.first