import bisect

N = int(eval(input()))

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

L.sort()

ans = 0

for b in range(N):

    l = b + 1

    for a in range(b):

        maxL = L[a] + L[b]

        r = bisect.bisect_left(L, maxL)

        ans += max(0, r-l)

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

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

L.sort()

ans = 0

for b in range(N):

    l = b + 1

    r = l

    for a in range(b):

        maxL = L[a] + L[b]

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

        ans += max(0, r-l)

print(ans)
import bisect

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

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

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