from bisect import bisect_left



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

X = sorted(L)

ans = 0

for i in range(N):

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

        ub = bisect_left(X, X[i] + X[j])

        ans += ub - (j + 1)

        

print(ans)



from bisect import bisect_left, bisect_right



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



X.sort()

ans = 0

for i in range(N - 2):

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

        k1 = bisect_right(X, X[j] - X[i])

        k2 = bisect_left(X, X[i] + X[j])

        k1 = max(k1, j + 1)

        ans += max(0, k2 - k1)



print(ans)

from bisect import bisect_left

N, *L = list(map(int, open(0).read().split()))
X = sorted(L)
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        ub = bisect_left(X, X[i] + X[j])
        ans += ub - (j + 1)
print(ans)

from bisect import bisect_left, bisect_right

N, *X = list(map(int, open(0).read().split()))
X.sort()
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k1 = bisect_right(X, X[j] - X[i])
        k2 = bisect_left(X, X[i] + X[j])
        k1 = max(k1, j + 1)
        ans += max(0, k2 - k1)
print(ans)

-from bisect import bisect_left +from bisect import bisect_left, bisect_right -N, *L = list(map(int, open(0).read().split())) -X = sorted(L) +N, *X = list(map(int, open(0).read().split())) +X.sort() -for i in range(N): -    for j in range(i + 1, N): -        ub = bisect_left(X, X[i] + X[j]) -        ans += ub - (j + 1) +for i in range(N - 2): +    for j in range(i + 1, N - 1): +        k1 = bisect_right(X, X[j] - X[i]) +        k2 = bisect_left(X, X[i] + X[j]) +        k1 = max(k1, j + 1) +        ans += max(0, k2 - k1)