import time

from bisect import bisect_left

n = int(eval(input()))

l = list(map(int, input().split()))

l = sorted(l)



start = time.time()

res = 0

for i in range(n):

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

        ab = l[i] + l[j]

        c_index = bisect_left(l, ab)

        res += c_index - j - 1

print(res)

from bisect import bisect_left



N = int(eval(input()))

Lmat = [int(n) for n in input().split()]

Lmat.sort()



sum = 0

for i in range(N):

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

        sum+= bisect_left(Lmat, Lmat[i]+Lmat[j]) - j - 1

print(sum)
import time
from bisect import bisect_left

n = int(eval(input()))
l = list(map(int, input().split()))
l = sorted(l)
start = time.time()
res = 0
for i in range(n):
    for j in range(i + 1, n):
        ab = l[i] + l[j]
        c_index = bisect_left(l, ab)
        res += c_index - j - 1
print(res)

from bisect import bisect_left

N = int(eval(input()))
Lmat = [int(n) for n in input().split()]
Lmat.sort()
sum = 0
for i in range(N):
    for j in range(i + 1, N):
        sum += bisect_left(Lmat, Lmat[i] + Lmat[j]) - j - 1
print(sum)

-import time -n = int(eval(input())) -l = list(map(int, input().split())) -l = sorted(l) -start = time.time() -res = 0 -for i in range(n): -    for j in range(i + 1, n): -        ab = l[i] + l[j] -        c_index = bisect_left(l, ab) -        res += c_index - j - 1 -print(res) +N = int(eval(input())) +Lmat = [int(n) for n in input().split()] +Lmat.sort() +sum = 0 +for i in range(N): +    for j in range(i + 1, N): +        sum += bisect_left(Lmat, Lmat[i] + Lmat[j]) - j - 1 +print(sum)