local function upper_bound(key,ary)
    local n=#ary
    if n==0 then
        return 1 
    end
    if key<ary[1] then
        return 1
    end
    if key>=ary[n] then
        return n+1
    end
    local min,max=1,n
    while 1<max-min do
        local mid=(min+max)//2
        if key>=ary[mid] then
            min=mid
        else
            max=mid
        end
    end
    return max
end

n=io.read("*n","*l")
l={}
for i=1,n do
    l[i]=io.read("*n")
end
table.sort(l)
counter=0
for i=n,3,-1 do
    large=l[i]
    for j=i-1,2,-1 do
        middle=l[j]
        if middle*2<=large then
            break
        end
        local smallmin=upper_bound(large-middle,l)
        print(smallmin)
        if smallmin<j then
            counter=counter+j-smallmin
        end
    end
end
print(counter)