import bisect

N=int(eval(input()))

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

#a<b+c

#b<c+a

#c<a+b

#a<=b<=c

#c<a+b

L=sorted(L)

ans=0

for i in range(N-2):

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

        x=bisect.bisect_left(L,L[i]+L[j])

        ans+=x-(j+1)

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

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

L=sorted(L)

import bisect



ans=0

for i in range(N-1):

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

        a=L[i]

        b=L[j]

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

        lower=max(j+1, bisect.bisect_right(L, a-b), bisect.bisect_right(L, b-a))

        #print(upper, lower)

        ans+=max(0, upper-lower)





print(ans)
import bisect

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

N = int(eval(input()))
L = list(map(int, input().split()))
L = sorted(L)
import bisect

ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        a = L[i]
        b = L[j]
        upper = bisect.bisect_left(L, a + b)
        lower = max(j + 1, bisect.bisect_right(L, a - b), bisect.bisect_right(L, b - a))
        # print(upper, lower)
        ans += max(0, upper - lower)
print(ans)

+N = int(eval(input())) +L = list(map(int, input().split())) +L = sorted(L) -N = int(eval(input())) -L = list(map(int, input().split())) -# a<b+c -# b<c+a -# c<a+b -# a<=b<=c -# c<a+b -L = sorted(L) -for i in range(N - 2): -    for j in range(i + 1, N - 1): -        x = bisect.bisect_left(L, L[i] + L[j]) -        ans += x - (j + 1) +for i in range(N - 1): +    for j in range(i + 1, N): +        a = L[i] +        b = L[j] +        upper = bisect.bisect_left(L, a + b) +        lower = max(j + 1, bisect.bisect_right(L, a - b), bisect.bisect_right(L, b - a)) +        # print(upper, lower) +        ans += max(0, upper - lower)