from itertools import *

N = int(eval(input()))

csum = list(0 for _ in range(2000+1))

L = []

for l in map(int,input().split()):

    L.append(l)

    csum[l] += 1

csum = list(accumulate(csum))

ans = 0

for ia in range(N-1):

    for ib in range(ia+1,N):

        a, b = L[ia], L[ib]

        minL, maxL = abs(a-b), a+b

        ans += csum[maxL-1] - csum[minL]

        if minL < a and a < maxL: ans -= 1

        if minL < b and b < maxL: ans -= 1

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

csum = list(0 for _ in range(2000+1))

L = []

for l in map(int,input().split()):

    L.append(l)

    csum[l] += 1

for i in range(1,len(csum)): csum[i] += csum[i-1]

ans = 0

for ib in range(N):

    b = L[ib]

    for ia in range(ib):

        a = L[ia]

        minL, maxL = abs(a-b), a+b

        ans += csum[maxL-1] - csum[minL]

        if minL < a < maxL: ans -= 1

        if minL < b < maxL: ans -= 1

print((ans//3))
from itertools import *

N = int(eval(input()))
csum = list(0 for _ in range(2000 + 1))
L = []
for l in map(int, input().split()):
    L.append(l)
    csum[l] += 1
csum = list(accumulate(csum))
ans = 0
for ia in range(N - 1):
    for ib in range(ia + 1, N):
        a, b = L[ia], L[ib]
        minL, maxL = abs(a - b), a + b
        ans += csum[maxL - 1] - csum[minL]
        if minL < a and a < maxL:
            ans -= 1
        if minL < b and b < maxL:
            ans -= 1
print((ans // 3))

N = int(eval(input()))
csum = list(0 for _ in range(2000 + 1))
L = []
for l in map(int, input().split()):
    L.append(l)
    csum[l] += 1
for i in range(1, len(csum)):
    csum[i] += csum[i - 1]
ans = 0
for ib in range(N):
    b = L[ib]
    for ia in range(ib):
        a = L[ia]
        minL, maxL = abs(a - b), a + b
        ans += csum[maxL - 1] - csum[minL]
        if minL < a < maxL:
            ans -= 1
        if minL < b < maxL:
            ans -= 1
print((ans // 3))

-from itertools import * - -csum = list(accumulate(csum)) +for i in range(1, len(csum)): +    csum[i] += csum[i - 1] -for ia in range(N - 1): -    for ib in range(ia + 1, N): -        a, b = L[ia], L[ib] +for ib in range(N): +    b = L[ib] +    for ia in range(ib): +        a = L[ia] -        if minL < a and a < maxL: +        if minL < a < maxL: -        if minL < b and b < maxL: +        if minL < b < maxL: