from bisect import*

n,*l=list(map(int,open(0).read().split()))

l.sort()

A=0

for i in range(n):

    a=l[i]

    for j in range(i+1,n):

        b=l[j]

        k1=max(j+1,bisect(l,b-a))

        k2=bisect_left(l,a+b)

        A+=max(0,k2-k1)

print(A)
from bisect import*

n,*l=list(map(int,open(0).read().split()))

l.sort()

print((sum(~j+bisect_left(l,l[i]+l[j],j+1)for i in range(n)for j in range(i+1,n))))
from bisect import *

n, *l = list(map(int, open(0).read().split()))
l.sort()
A = 0
for i in range(n):
    a = l[i]
    for j in range(i + 1, n):
        b = l[j]
        k1 = max(j + 1, bisect(l, b - a))
        k2 = bisect_left(l, a + b)
        A += max(0, k2 - k1)
print(A)

from bisect import *

n, *l = list(map(int, open(0).read().split()))
l.sort()
print(
    (
        sum(
            ~j + bisect_left(l, l[i] + l[j], j + 1)
            for i in range(n)
            for j in range(i + 1, n)
        )
    )
)

-A = 0 -for i in range(n): -    a = l[i] -    for j in range(i + 1, n): -        b = l[j] -        k1 = max(j + 1, bisect(l, b - a)) -        k2 = bisect_left(l, a + b) -        A += max(0, k2 - k1) -print(A) +print( +    ( +        sum( +            ~j + bisect_left(l, l[i] + l[j], j + 1) +            for i in range(n) +            for j in range(i + 1, n) +        ) +    ) +)