N = gets.chomp K = gets.chomp num = STDIN.readlines.map(&:chomp) a = num.map(&:to_i).sort diff = a.last - a.first puts diff