import bisect



n = int(eval(input()))

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



a = sorted(lis, reverse=True)

c = sorted(lis)

d = 0



for i in range(n):

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

        e = c[:-j-1]

        b = bisect.bisect_right(e, int(a[i]-a[j]))

        d += max(0, len(e) - b)

print(d)

import bisect



n = int(eval(input()))

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

lis.sort()



d = 0



for i in range(n-2):

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

        b = bisect.bisect_left(lis, int(lis[i] + lis[j]))

        d += max(0, b - j - 1)

print(d)

import bisect

n = int(eval(input()))
lis = list(map(int, input().split()))
a = sorted(lis, reverse=True)
c = sorted(lis)
d = 0
for i in range(n):
    for j in range(i + 1, n):
        e = c[: -j - 1]
        b = bisect.bisect_right(e, int(a[i] - a[j]))
        d += max(0, len(e) - b)
print(d)

import bisect

n = int(eval(input()))
lis = list(map(int, input().split()))
lis.sort()
d = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        b = bisect.bisect_left(lis, int(lis[i] + lis[j]))
        d += max(0, b - j - 1)
print(d)

-a = sorted(lis, reverse=True) -c = sorted(lis) +lis.sort() -for i in range(n): -    for j in range(i + 1, n): -        e = c[: -j - 1] -        b = bisect.bisect_right(e, int(a[i] - a[j])) -        d += max(0, len(e) - b) +for i in range(n - 2): +    for j in range(i + 1, n - 1): +        b = bisect.bisect_left(lis, int(lis[i] + lis[j])) +        d += max(0, b - j - 1)