import bisect

N = int(eval(input()))

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

L.sort()

ans = 0

for b in range(N):

    for a in range(b):

        ans += bisect.bisect_left(L, L[a] + L[b])-(b+1)

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

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

L.sort()

ans = 0

for b in range(N):

    r = b + 1

    for a in range(b):

        while r<N and L[r]<L[a]+L[b]: r += 1

        ans += r-(b+1)

print(ans)
import bisect

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

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

-import bisect - +    r = b + 1 -        ans += bisect.bisect_left(L, L[a] + L[b]) - (b + 1) +        while r < N and L[r] < L[a] + L[b]: +            r += 1 +        ans += r - (b + 1)