from bisect import*;N,*L=list(map(int,open(0).read().split()));L.sort();print((sum(bisect_left(L,L[i]+L[j],j+1)-j-1for 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();print((sum(j-bisect(L,L[i]-L[j],0,j)for i in range(N)for j in range(i))))
from bisect import *

N, *L = list(map(int, open(0).read().split()))
L.sort()
print(
    (
        sum(
            bisect_left(L, L[i] + L[j], j + 1) - 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()
print((sum(j - bisect(L, L[i] - L[j], 0, j) for i in range(N) for j in range(i))))

-print( -    ( -        sum( -            bisect_left(L, L[i] + L[j], j + 1) - j - 1 -            for i in range(N) -            for j in range(i + 1, N) -        ) -    ) -) +print((sum(j - bisect(L, L[i] - L[j], 0, j) for i in range(N) for j in range(i))))