n = gets.to_i
arr = gets.split(" ")

hash = {}
arr.each { |num|
  if hash[num]
    hash[num] += 1
  else
    hash[num] = 1
  end
}

cmbs = hash.keys.combination(3).map {|arr| arr.map(&:to_i) }

count = 0

cmbs.each do |c|
  if c[0]+c[1] > c[2] && c[1]+c[2] > c[0] && c[0]+c[2] > c[1]
    count = count + hash[c[0].to_s] * hash[c[1].to_s] * hash[c[2].to_s]
  end
end

p count

