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
        t = l[a] + l[b]
        c = l.bsearch_index{|x| x >= t}

        left = b+1
        right = c
        ans += (c ? c : n) - (b + 1)
    end
end

puts ans