import bisect

from bisect import bisect_left

n = int(eval(input()))

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

l = sorted(l)

ans = 0



for i in range(n):

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

    s = l[i]+l[j]

    ans += bisect_left(l[j+1:n], s)



print(ans)

import bisect

N = int(eval(input()))

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

L = sorted(L)



ans = 0

for i in range(N):

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

    idx = bisect.bisect_left(L[j+1:], L[i]+L[j])

    ans += idx 

print(ans)

    
import bisect
from bisect import bisect_left

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

import bisect

N = int(eval(input()))
L = list(map(int, input().split()))
L = sorted(L)
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        idx = bisect.bisect_left(L[j + 1 :], L[i] + L[j])
        ans += idx
print(ans)

-from bisect import bisect_left -n = int(eval(input())) -l = list(map(int, input().split())) -l = sorted(l) +N = int(eval(input())) +L = list(map(int, input().split())) +L = sorted(L) -for i in range(n): -    for j in range(n - 1, i, -1): -        s = l[i] + l[j] -        ans += bisect_left(l[j + 1 : n], s) +for i in range(N): +    for j in range(i + 1, N): +        idx = bisect.bisect_left(L[j + 1 :], L[i] + L[j]) +        ans += idx