import bisect

from copy import deepcopy

N = int(eval(input()))

L = sorted(map(int, input().split()))



ans = 0

for i in range(N):

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

        b = L[j] + L[i]

        x = bisect.bisect_left(L, b) - j - 1

        if x > 0:

            ans += x



print(ans)

import bisect

n = int(eval(input()))

L = sorted(map(int, input().split()))

m = L[-1]

ans = 0

for i in range(n):

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

        k = L[i] + L[j]

        ans += bisect.bisect_left(L, k) - j-1

print(ans)

import bisect
from copy import deepcopy

N = int(eval(input()))
L = sorted(map(int, input().split()))
ans = 0
for i in range(N):
    for j in range(i + 1, N - 1):
        b = L[j] + L[i]
        x = bisect.bisect_left(L, b) - j - 1
        if x > 0:
            ans += x
print(ans)

import bisect

n = int(eval(input()))
L = sorted(map(int, input().split()))
m = L[-1]
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        k = L[i] + L[j]
        ans += bisect.bisect_left(L, k) - j - 1
print(ans)

-from copy import deepcopy -N = int(eval(input())) +n = int(eval(input())) +m = L[-1] -for i in range(N): -    for j in range(i + 1, N - 1): -        b = L[j] + L[i] -        x = bisect.bisect_left(L, b) - j - 1 -        if x > 0: -            ans += x +for i in range(n): +    for j in range(i + 1, n): +        k = L[i] + L[j] +        ans += bisect.bisect_left(L, k) - j - 1