def extract_new(arr) dic = {} arr.each do |i| if dic[i].nil? dic[i] = 0 else dic[i] += 1 end end new = [] dic.each { |k, v| new << {key: k, value: v} } new = new.select { |d| d[:value] == 0}.map {|d| d[:key]} new.size end n = gets.to_i data = gets.split.map(&:to_i) puts extract_new(data)