N = gets.to_i K = gets.to_i arr = [] N.times do arr << gets.to_i end arr.sort!{|a, b| b <=> a} puts arr.first - arr.last