N = gets.to_i K = gets.to_i min = 1000 max = 0 N.times do n = gets.to_i min = n if n < min max = n if n > max end puts max - min