from bisect import bisect_left



N = int(eval(input()))

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

L.sort()



ans = 0

for i in range(N):

    a = L[i]

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

        b = L[j]



        idx = bisect_left(L, a+b)

        ans += max(idx - (j+1), 0)



print(ans)

N = int(eval(input()))

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

L.sort()



ans = 0

for i in range(N):

    k = i

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

        while (k < N and L[k] < L[i]+L[j]):

            k += 1

        ans += k - (j+1)



print(ans)

from bisect import bisect_left

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    a = L[i]
    for j in range(i + 1, N):
        b = L[j]
        idx = bisect_left(L, a + b)
        ans += max(idx - (j + 1), 0)
print(ans)

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

-from bisect import bisect_left - -    a = L[i] +    k = i -        b = L[j] -        idx = bisect_left(L, a + b) -        ans += max(idx - (j + 1), 0) +        while k < N and L[k] < L[i] + L[j]: +            k += 1 +        ans += k - (j + 1)