from bisect import bisect_left



n = int(eval(input()))

l = sorted(list(map(int, input().split())))

answer = 0



for i in range(n - 2):

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

        lij = l[i] + l[j]

        r = bisect_left(l, lij)

        answer += max(0, r - j - 1)

        

print(answer)

from bisect import bisect_left



n = int(eval(input()))

l = sorted(list(map(int, input().split())))

answer = 0



for i in range(n - 2):

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

        lij = l[i] + l[j]

        r = bisect_left(l, lij)

        answer += r - j - 1

        

print(answer)

from bisect import bisect_left

n = int(eval(input()))
l = sorted(list(map(int, input().split())))
answer = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        lij = l[i] + l[j]
        r = bisect_left(l, lij)
        answer += max(0, r - j - 1)
print(answer)

from bisect import bisect_left

n = int(eval(input()))
l = sorted(list(map(int, input().split())))
answer = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        lij = l[i] + l[j]
        r = bisect_left(l, lij)
        answer += r - j - 1
print(answer)

-        answer += max(0, r - j - 1) +        answer += r - j - 1