local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
--
-- 1 <= input to f <= n
local function find_min_true(n, f)
    local function loop(i, j)
        if i == j then
            assert(i >= 1 and i <= n + 1)
            return i
        end
        local h = (i + j) // 2
        assert(h >= 1 and h <= n)
        if f(h) then
            return loop(i, h)
        else
            return loop(h + 1, j)
        end
    end
    return loop(1, n + 1)
end
--
local N = read.n()
local L = read.N(N)
table.sort(L)
local ans = 0
for i=1,N-2 do
    local a = L[i]
    for j=i+1,N-1 do
        local b = L[j]
        local function count()
            local function f(x)
                x = x + j -- [1,N-j] --> [j+1,N]
                local c = L[x]
                return c >= a + b
            end
            return find_min_true(N-j, f) - 1
        end
        ans = ans + count()
    end
end
print(ans)
