N = gets.to_i
ds = gets.split.map(&:to_i).sort
ks = ds.uniq
count = 0
half_index = ds.bsearch{|x| x == ds[N/2] }
arc = ds.select{|d| d >= half_index}.combination(3).count
abc = ds.select{|d| d < half_index}.combination(3).count
count += arc + abc if arc == abc
puts count
