n = gets.to_i
l = gets.split.map(&:to_i)

l.sort!

ans = 0
for a in 0...n-2
    for b in a+1...n-1
        c = l.bsearch_index{|x| x >= l[a]+l[b]}

        c = n unless c
        
        left = b+1
        right = c

        ans += [right - left, 0].max
    end
end

puts ans