import bisect

N = int(eval(input()))

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

L.sort()

ans = 0



for i in range(N-2):

    a = L[i]

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

        b = L[j]

        c = bisect.bisect_left(L,a+b)

        ans += c-j-1

print(ans)

n = int(eval(input()))

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

l.sort()



from bisect import bisect_left



ans = 0

for i in range(n):

    a = l[i]

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

        b = l[j]

        ans += bisect_left(l,a+b)-j-1

print(ans)

import bisect

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

n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
from bisect import bisect_left

ans = 0
for i in range(n):
    a = l[i]
    for j in range(i + 1, n):
        b = l[j]
        ans += bisect_left(l, a + b) - j - 1
print(ans)

-import bisect +n = int(eval(input())) +l = list(map(int, input().split())) +l.sort() +from bisect import bisect_left -N = int(eval(input())) -L = list(map(int, input().split())) -L.sort() -for i in range(N - 2): -    a = L[i] -    for j in range(i + 1, N - 1): -        b = L[j] -        c = bisect.bisect_left(L, a + b) -        ans += c - j - 1 +for i in range(n): +    a = l[i] +    for j in range(i + 1, n): +        b = l[j] +        ans += bisect_left(l, a + b) - j - 1