from bisect import bisect_left

n = int(eval(input()))

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

l.sort()

ans = 0

for i in range(n):

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

    left = l[j]-l[i]

    right = l[i]+l[j]

    ans += max(0, bisect_left(l, right) - (j+1))

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

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

l.sort()

lt = [n] * (l[n-1] + l[n-2] + 1)

ans = 0

for i in range(l[0]+1):

    lt[i] = 0

length = l[0]

for i in range(1, n):

  if length < l[i]:

    for j in range(length+1, l[i]+1):

      lt[j] = i

    length = l[i]

for i in range(n):

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

    right = l[i]+l[j]

    ans += max(0,  lt[right] - (j+1))

print(ans)
from bisect import bisect_left

n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        left = l[j] - l[i]
        right = l[i] + l[j]
        ans += max(0, bisect_left(l, right) - (j + 1))
print(ans)

n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
lt = [n] * (l[n - 1] + l[n - 2] + 1)
ans = 0
for i in range(l[0] + 1):
    lt[i] = 0
length = l[0]
for i in range(1, n):
    if length < l[i]:
        for j in range(length + 1, l[i] + 1):
            lt[j] = i
        length = l[i]
for i in range(n):
    for j in range(i + 1, n):
        right = l[i] + l[j]
        ans += max(0, lt[right] - (j + 1))
print(ans)

-from bisect import bisect_left - +lt = [n] * (l[n - 1] + l[n - 2] + 1) +for i in range(l[0] + 1): +    lt[i] = 0 +length = l[0] +for i in range(1, n): +    if length < l[i]: +        for j in range(length + 1, l[i] + 1): +            lt[j] = i +        length = l[i] -        left = l[j] - l[i] -        ans += max(0, bisect_left(l, right) - (j + 1)) +        ans += max(0, lt[right] - (j + 1))