from bisect import bisect

from bisect import bisect_left

n = int(eval(input()))

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

l.sort()

ans = 0

for i in range(n):

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

    left = l[j]-l[i]

    right = l[i]+l[j]

    ans += max(0, bisect_left(l, right) - max(j+1, bisect(l,left)))

print(ans)
from bisect import bisect_left

n = int(eval(input()))

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

l.sort()

ans = 0

for i in range(n):

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

    left = l[j]-l[i]

    right = l[i]+l[j]

    ans += max(0, bisect_left(l, right) - (j+1))

print(ans)
from bisect import bisect
from bisect import bisect_left

n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        left = l[j] - l[i]
        right = l[i] + l[j]
        ans += max(0, bisect_left(l, right) - max(j + 1, bisect(l, left)))
print(ans)

from bisect import bisect_left

n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        left = l[j] - l[i]
        right = l[i] + l[j]
        ans += max(0, bisect_left(l, right) - (j + 1))
print(ans)

-from bisect import bisect -        ans += max(0, bisect_left(l, right) - max(j + 1, bisect(l, left))) +        ans += max(0, bisect_left(l, right) - (j + 1))