import bisect



N = int(eval(input()))

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



L.sort()

ans = 0

for i in range(N-2):

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

        index = bisect.bisect_right(L, L[i] + L[j]-1)

        ans += index - j - 1



print(ans)







from bisect import bisect_left



N = int(eval(input()))

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

L.sort()

ans = 0

for i in range(N):

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

        x = L[i] + L[j]

        y = bisect_left(L, x)

        ans += y - j - 1

print(ans)
import bisect

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        index = bisect.bisect_right(L, L[i] + L[j] - 1)
        ans += index - j - 1
print(ans)

from bisect import bisect_left

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        x = L[i] + L[j]
        y = bisect_left(L, x)
        ans += y - j - 1
print(ans)

-import bisect +from bisect import bisect_left -for i in range(N - 2): -    for j in range(i + 1, N - 1): -        index = bisect.bisect_right(L, L[i] + L[j] - 1) -        ans += index - j - 1 +for i in range(N): +    for j in range(i + 1, N): +        x = L[i] + L[j] +        y = bisect_left(L, x) +        ans += y - j - 1