import bisect

N = int(eval(input()))

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

res = 0

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

    for j in range(i - 1, 0, - 1):

        k = L[i] - L[j] + 1

        if k > L[j - 1]:

            break

        res += j - bisect.bisect_left(L, k)

print(res)
N = int(eval(input()))

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

res = 0

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

    j = i - 1

    k = 0

    while j > k:

        while j > k and L[i] >= L[j] + L[k]:

            k += 1

        res += j - k

        j -= 1

print(res)
import bisect

N = int(eval(input()))
L = sorted(list(map(int, input().split())))
res = 0
for i in range(N - 1, 1, -1):
    for j in range(i - 1, 0, -1):
        k = L[i] - L[j] + 1
        if k > L[j - 1]:
            break
        res += j - bisect.bisect_left(L, k)
print(res)

N = int(eval(input()))
L = sorted(list(map(int, input().split())))
res = 0
for i in range(N - 1, 1, -1):
    j = i - 1
    k = 0
    while j > k:
        while j > k and L[i] >= L[j] + L[k]:
            k += 1
        res += j - k
        j -= 1
print(res)

-import bisect - -    for j in range(i - 1, 0, -1): -        k = L[i] - L[j] + 1 -        if k > L[j - 1]: -            break -        res += j - bisect.bisect_left(L, k) +    j = i - 1 +    k = 0 +    while j > k: +        while j > k and L[i] >= L[j] + L[k]: +            k += 1 +        res += j - k +        j -= 1