N = gets.chomp.to_i
inputs = gets.chomp.split(" ").map(&:to_i).sort.reverse
count = 0
inputs.each_with_index do |e,i|
  j = i+1
  k=-1
  while N - j + k >0 do
    if inputs[i] < inputs[j]+inputs[k]
      count += N-j+k
      j += 1
    else
      k -= 1
    end
  end
end
 
puts count
