import bisect



n=int(eval(input()))

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



ans=0

for i in range(n-1):

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

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

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



print(ans)
import bisect

n=int(eval(input()))

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



ans=0

for i in range(n-1):

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

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

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

print(ans)

      
import bisect

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

import bisect

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

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