from bisect import bisect_left





N = int(eval(input()))

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

ans = 0

for i in range(2, N):

    c = L[i]

    for j in range(i):

        b = L[j]

        a_min_idx = bisect_left(L, c - b + 1, 0, j)

        ans += j - a_min_idx

print(ans)

# 34:14

from bisect import bisect_left





N = int(eval(input()))

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

ans = sum(

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

)

print(ans)

from bisect import bisect_left

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

# 34:14
from bisect import bisect_left

N = int(eval(input()))
L = sorted(map(int, input().split()))
ans = sum(
    j - bisect_left(L, L[i] - L[j] + 1, 0, j) for i in range(2, N) for j in range(i)
)
print(ans)

+# 34:14 -ans = 0 -for i in range(2, N): -    c = L[i] -    for j in range(i): -        b = L[j] -        a_min_idx = bisect_left(L, c - b + 1, 0, j) -        ans += j - a_min_idx +ans = sum( +    j - bisect_left(L, L[i] - L[j] + 1, 0, j) for i in range(2, N) for j in range(i) +)