from bisect import bisect_left



N = int(eval(input()))

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

L.sort()

answer = 0

for i in range(N):

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

        answer += bisect_left(L[j+1:], L[i]+L[j])

print(answer)

N = int(eval(input()))

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

L.sort()

answer = 0

for i in range(N-1, 1, -1): # iは辺の最大値

    s = 0 # aは1番短い辺

    l = i-1

    while l > s:

        if L[s] + L[l] > L[i]:

            answer += l - s

            l -= 1

        else:

            s += 1

print(answer)

from bisect import bisect_left

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
answer = 0
for i in range(N):
    for j in range(i + 1, N):
        answer += bisect_left(L[j + 1 :], L[i] + L[j])
print(answer)

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
answer = 0
for i in range(N - 1, 1, -1):  # iは辺の最大値
    s = 0  # aは1番短い辺
    l = i - 1
    while l > s:
        if L[s] + L[l] > L[i]:
            answer += l - s
            l -= 1
        else:
            s += 1
print(answer)

-from bisect import bisect_left - -for i in range(N): -    for j in range(i + 1, N): -        answer += bisect_left(L[j + 1 :], L[i] + L[j]) +for i in range(N - 1, 1, -1):  # iは辺の最大値 +    s = 0  # aは1番短い辺 +    l = i - 1 +    while l > s: +        if L[s] + L[l] > L[i]: +            answer += l - s +            l -= 1 +        else: +            s += 1