from bisect import bisect_right



n = int(eval(input()))

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

r = 0

for i in range(2, n):

    j = i - 1

    while j and a[j - 1] + a[j] > a[i]:

        r += j - bisect_right(a, a[i] - a[j], 0, j)

        j -= 1

print(r)

from bisect import bisect_right



n = int(eval(input()))

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

print((sum(j - bisect_right(a, a[i] - a[j], 0, j)

          for i in range(2, n) for j in range(1, i))))

from bisect import bisect_right

n = int(eval(input()))
a = sorted(map(int, input().split()))
r = 0
for i in range(2, n):
    j = i - 1
    while j and a[j - 1] + a[j] > a[i]:
        r += j - bisect_right(a, a[i] - a[j], 0, j)
        j -= 1
print(r)

from bisect import bisect_right

n = int(eval(input()))
a = sorted(map(int, input().split()))
print(
    (
        sum(
            j - bisect_right(a, a[i] - a[j], 0, j)
            for i in range(2, n)
            for j in range(1, i)
        )
    )
)

-r = 0 -for i in range(2, n): -    j = i - 1 -    while j and a[j - 1] + a[j] > a[i]: -        r += j - bisect_right(a, a[i] - a[j], 0, j) -        j -= 1 -print(r) +print( +    ( +        sum( +            j - bisect_right(a, a[i] - a[j], 0, j) +            for i in range(2, n) +            for j in range(1, i) +        ) +    ) +)