class A def initialize n = gets.chomp.to_i a = gets.chomp.split(' ').map(&:to_i) count = 0 a.uniq.combination(3) do |list| count += list.inject(1){|sum, i| sum *= a.count(i)} end puts count end end A.new