gets.to_i result = [] gets.split.map(&:to_i).uniq.sort.each_cons(2) do |a, b| result.push (a - b).abs end puts result.min