$n = gets.chomp.to_i
$rod = gets.chomp.split(" ").map(&:to_i).sort
ans = 0

def binary_search(key)
    left = -1
    right = $n
    while right - left > 1 do
        mid = left + (right - left) / 2
        if $rod[mid] >= key then
            right = mid
        else
            left = mid
        end
    end
    return left
end

$n.times do |a|
    (a+1).upto($n-1) do |b|
        tmp = $rod[a] + $rod[b]
        c = binary_search(tmp)
        ans += c-b if b-a < c
    end
end

puts ans