from itertools import accumulate



N, *L = list(map(int, open(0).read().split()))



A = [0] * (2 * 10 ** 3 + 7)

for l in L:

    A[l] += 1



S = list(accumulate(A))



ans = 0

for i in range(N):

    b = L[i]

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

        c = L[j]

        l, r = abs(b - c), b + c

        ans += S[r - 1] - S[l] - (l < b < r) - (l < c < r)



print((ans // 3))

from itertools import accumulate, combinations



N, *L = list(map(int, open(0).read().split()))



A = [0] * (2 * 10 ** 3 + 7)

for l in L:

    A[l] += 1



S = list(accumulate(A))



ans = 0

for b, c in combinations(L, 2):

    l, r = abs(b - c), b + c

    ans += S[r - 1] - S[l] - (l < b < r) - (l < c < r)



print((ans // 3))

from itertools import accumulate

N, *L = list(map(int, open(0).read().split()))
A = [0] * (2 * 10**3 + 7)
for l in L:
    A[l] += 1
S = list(accumulate(A))
ans = 0
for i in range(N):
    b = L[i]
    for j in range(i + 1, N):
        c = L[j]
        l, r = abs(b - c), b + c
        ans += S[r - 1] - S[l] - (l < b < r) - (l < c < r)
print((ans // 3))

from itertools import accumulate, combinations

N, *L = list(map(int, open(0).read().split()))
A = [0] * (2 * 10**3 + 7)
for l in L:
    A[l] += 1
S = list(accumulate(A))
ans = 0
for b, c in combinations(L, 2):
    l, r = abs(b - c), b + c
    ans += S[r - 1] - S[l] - (l < b < r) - (l < c < r)
print((ans // 3))

-from itertools import accumulate +from itertools import accumulate, combinations -for i in range(N): -    b = L[i] -    for j in range(i + 1, N): -        c = L[j] -        l, r = abs(b - c), b + c -        ans += S[r - 1] - S[l] - (l < b < r) - (l < c < r) +for b, c in combinations(L, 2): +    l, r = abs(b - c), b + c +    ans += S[r - 1] - S[l] - (l < b < r) - (l < c < r)