from bisect import bisect

from bisect import bisect_left



n = int(eval(input()))

l = eval(input())

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

count = 0



for i in range(n):

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

		c = l[i]+l[j]

		count += bisect_left(l,c) - (j+1)



print(count)

from bisect import bisect

from bisect import bisect_left



_ = eval(input())

l = eval(input())

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

count = 0



for i in range(len(l)):

	for j in range(i+1, len(l)):

		

		count += bisect_left(l,l[i]+l[j]) - (j+1)



print(count)

from bisect import bisect
from bisect import bisect_left

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

from bisect import bisect
from bisect import bisect_left

_ = eval(input())
l = eval(input())
l = sorted(list(map(int, l.split())))
count = 0
for i in range(len(l)):
    for j in range(i + 1, len(l)):
        count += bisect_left(l, l[i] + l[j]) - (j + 1)
print(count)

-n = int(eval(input())) +_ = eval(input()) -for i in range(n): -    for j in range(i + 1, n): -        c = l[i] + l[j] -        count += bisect_left(l, c) - (j + 1) +for i in range(len(l)): +    for j in range(i + 1, len(l)): +        count += bisect_left(l, l[i] + l[j]) - (j + 1)