N = gets.chomp.to_i
L = gets.chomp.split(" ").map(&:to_i)

L.sort!

def bsearch(array, value)
  return nil if array.first >= value
  left = -1
  right = array.size
  while left + 1 < right do
    idx = left + (right - left) / 2
    if array[idx] > value then
      right = idx
    else
      left = idx
    end
  end
  right
end

sum = 0
L.each.with_index do |a,ai|
  L[ai..-2].each.with_index do |b,bi|
    next if ai == ai + bi
    l = L.clone[ai+bi+1..-1]
    # p "a = #{a}, b = #{b}, a + b = #{a + b}, l = #{l}"
    # p bsearch(l, a + b)
    i = bsearch(l, a + b)
    next if i == nil
    sum += i
  end
end

puts sum