from bisect import*

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

l.sort();c=0

for i in range(n):

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

    d = bisect_left(l, l[i] + l[j])

    c += max(0, d-j-1)

print(c)
from bisect import*

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

l.sort()

print((sum(max(0, 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()
c = 0
for i in range(n):
    for j in range(i + 1, n):
        d = bisect_left(l, l[i] + l[j])
        c += max(0, d - j - 1)
print(c)

from bisect import *

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

-c = 0 -for i in range(n): -    for j in range(i + 1, n): -        d = bisect_left(l, l[i] + l[j]) -        c += max(0, d - j - 1) -print(c) +print( +    ( +        sum( +            max(0, bisect_left(l, l[i] + l[j]) - j - 1) +            for i in range(n) +            for j in range(i + 1, n) +        ) +    ) +)