def binary_search(arr, key)
    left = -1
    right = arr.size()
    while right - left > 1 do
        mid = left + (right - left) / 2
        if arr[mid] >= key then
            right = mid
        else
            left = mid
        end
    end
    return left
end

n = gets.chomp.to_i
rod = gets.chomp.split(" ").map(&:to_i).sort
ans = 0
n.times do |a|
    (a+1).upto(n-1) do |b|
        tmp = rod[b] + rod[a]
        c = binary_search(rod, tmp)
        ans += c-b if b-a < c
    end
end

puts ans