from bisect import bisect_right



N = int(eval(input()))

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



L_sorted = sorted(L)



count = 0

for i in range(N):  # longest stick

    for j in range(i):  # second longest stick

        r = bisect_right(L_sorted, L_sorted[i] - L_sorted[j])

        count += max(0, j - r)



print(count)


from bisect import bisect_right



N = int(eval(input()))

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



L_sorted = sorted(L)



count = 0

for i in range(N):  # longest stick

    for j in reversed(list(range(i))):  # second longest stick

        r = bisect_right(L_sorted, L_sorted[i] - L_sorted[j])

        if j <= r:

            break

        else:

            count += j - r



print(count)
from bisect import bisect_right

N = int(eval(input()))
L = list(map(int, input().split()))
L_sorted = sorted(L)
count = 0
for i in range(N):  # longest stick
    for j in range(i):  # second longest stick
        r = bisect_right(L_sorted, L_sorted[i] - L_sorted[j])
        count += max(0, j - r)
print(count)

from bisect import bisect_right

N = int(eval(input()))
L = list(map(int, input().split()))
L_sorted = sorted(L)
count = 0
for i in range(N):  # longest stick
    for j in reversed(list(range(i))):  # second longest stick
        r = bisect_right(L_sorted, L_sorted[i] - L_sorted[j])
        if j <= r:
            break
        else:
            count += j - r
print(count)

-    for j in range(i):  # second longest stick +    for j in reversed(list(range(i))):  # second longest stick -        count += max(0, j - r) +        if j <= r: +            break +        else: +            count += j - r