N = int(eval(input()))

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

L.sort()

 

from bisect import bisect_left 

cnt = 0

for i in range(0,N-2):

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

    t = L[i]+L[j]

    idx = bisect_left(L,t)

    cnt += max(0,idx-j-1)

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

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

L.sort()

 

from bisect import bisect_left 

cnt = 0

for i in range(0,N-2):

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

    t = L[i]+L[j]

    idx = bisect_left(L,t,j+1)

    cnt += max(0,idx-j-1)

print(cnt)
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
from bisect import bisect_left

cnt = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        t = L[i] + L[j]
        idx = bisect_left(L, t)
        cnt += max(0, idx - j - 1)
print(cnt)

N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
from bisect import bisect_left

cnt = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        t = L[i] + L[j]
        idx = bisect_left(L, t, j + 1)
        cnt += max(0, idx - j - 1)
print(cnt)

-        idx = bisect_left(L, t) +        idx = bisect_left(L, t, j + 1)