N = int(eval(input()))

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

L.sort()

cmax = L[-1] + L[-2]

csum = list(0 for _ in range(cmax+1))

for i in range(N): csum[L[i]] += 1

for i in range(1,cmax+1): csum[i] += csum[i-1]

ans = 0

for ib in range(N):

    b = L[ib]

    for ia in range(ib):

        a = L[ia]

        minL, maxL = abs(a-b), a+b

        ans += csum[maxL-1] - csum[minL]

        if minL < a < maxL: ans -= 1

        if minL < b < maxL: ans -= 1

print((ans//3))
import bisect

N = int(eval(input()))

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

L.sort()

ans = 0

for b in range(N):

    for a in range(b):

        ans += bisect.bisect_left(L, L[a] + L[b])-(b+1)

print(ans)
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
cmax = L[-1] + L[-2]
csum = list(0 for _ in range(cmax + 1))
for i in range(N):
    csum[L[i]] += 1
for i in range(1, cmax + 1):
    csum[i] += csum[i - 1]
ans = 0
for ib in range(N):
    b = L[ib]
    for ia in range(ib):
        a = L[ia]
        minL, maxL = abs(a - b), a + b
        ans += csum[maxL - 1] - csum[minL]
        if minL < a < maxL:
            ans -= 1
        if minL < b < maxL:
            ans -= 1
print((ans // 3))

import bisect

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for b in range(N):
    for a in range(b):
        ans += bisect.bisect_left(L, L[a] + L[b]) - (b + 1)
print(ans)

+import bisect + -cmax = L[-1] + L[-2] -csum = list(0 for _ in range(cmax + 1)) -for i in range(N): -    csum[L[i]] += 1 -for i in range(1, cmax + 1): -    csum[i] += csum[i - 1] -for ib in range(N): -    b = L[ib] -    for ia in range(ib): -        a = L[ia] -        minL, maxL = abs(a - b), a + b -        ans += csum[maxL - 1] - csum[minL] -        if minL < a < maxL: -            ans -= 1 -        if minL < b < maxL: -            ans -= 1 -print((ans // 3)) +for b in range(N): +    for a in range(b): +        ans += bisect.bisect_left(L, L[a] + L[b]) - (b + 1) +print(ans)