N = gets.to_i
L = gets.split.map(&:to_i).sort.reverse

count = 0
for i in 0..(N-3)
  for j in (i+1)..(N-2)
    for k in (j+1)..(N-1)
      count += 1 if L[i] < L[j] + L[k]
    end
  end
end

puts count