N = int(eval(input()))

A = sorted([int(a) for a in input().split()])

X = [0] * 1001

for a in A:

    X[a] += 1

for i in range(1, 1001):

    X[i] += X[i-1]



ans = 0

for i in range(N):

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

        ans += X[min(A[i]+A[j]-1, 1000)] - (j+1)

print(ans)
k = 31

K = 1<<k

nu = lambda L: int("".join([bin(K+a)[-k:] for a in L[::-1]]), 2)

st = lambda n: bin(n)[2:] + "0"

li = lambda s: [int(a, 2) if len(a) else 0 for a in [s[-(i+1)*k-1:-i*k-1] for i in range(1001)]]



N = int(eval(input()))

A = [int(a) for a in input().split()]

C = [0] * 1001

for a in A:

    C[a] += 1

B = li(st(nu(C) ** 2))

for a in A:

    if a <= 500: B[2*a] -= 1

for i in range(1001):

    B[i] //= 2

for i in range(1, 1001):

    C[i] += C[i-1]

ans = N*(N-1)*(N-2)//6

for i in range(1, 1001):

    ans -= (N-C[i-1]) * B[i]

print(ans)

N = int(eval(input()))
A = sorted([int(a) for a in input().split()])
X = [0] * 1001
for a in A:
    X[a] += 1
for i in range(1, 1001):
    X[i] += X[i - 1]
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        ans += X[min(A[i] + A[j] - 1, 1000)] - (j + 1)
print(ans)

k = 31
K = 1 << k
nu = lambda L: int("".join([bin(K + a)[-k:] for a in L[::-1]]), 2)
st = lambda n: bin(n)[2:] + "0"
li = lambda s: [
    int(a, 2) if len(a) else 0
    for a in [s[-(i + 1) * k - 1 : -i * k - 1] for i in range(1001)]
]
N = int(eval(input()))
A = [int(a) for a in input().split()]
C = [0] * 1001
for a in A:
    C[a] += 1
B = li(st(nu(C) ** 2))
for a in A:
    if a <= 500:
        B[2 * a] -= 1
for i in range(1001):
    B[i] //= 2
for i in range(1, 1001):
    C[i] += C[i - 1]
ans = N * (N - 1) * (N - 2) // 6
for i in range(1, 1001):
    ans -= (N - C[i - 1]) * B[i]
print(ans)

+k = 31 +K = 1 << k +nu = lambda L: int("".join([bin(K + a)[-k:] for a in L[::-1]]), 2) +st = lambda n: bin(n)[2:] + "0" +li = lambda s: [ +    int(a, 2) if len(a) else 0 +    for a in [s[-(i + 1) * k - 1 : -i * k - 1] for i in range(1001)] +] -A = sorted([int(a) for a in input().split()]) -X = [0] * 1001 +A = [int(a) for a in input().split()] +C = [0] * 1001 -    X[a] += 1 +    C[a] += 1 +B = li(st(nu(C) ** 2)) +for a in A: +    if a <= 500: +        B[2 * a] -= 1 +for i in range(1001): +    B[i] //= 2 -    X[i] += X[i - 1] -ans = 0 -for i in range(N): -    for j in range(i + 1, N): -        ans += X[min(A[i] + A[j] - 1, 1000)] - (j + 1) +    C[i] += C[i - 1] +ans = N * (N - 1) * (N - 2) // 6 +for i in range(1, 1001): +    ans -= (N - C[i - 1]) * B[i]