import bisect

N=int(eval(input()))

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



ans=0

for i in range(N-2):

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

    # ans+=bisect.bisect_left(L,L[i]+L[j])-j-1

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

print(ans)
import bisect

N=int(eval(input()))

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



ans=0

for i in range(N-2):

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

    ans+=bisect.bisect_left(L,L[i]+L[j])-j-1 # Code 1 

    # ans+=bisect.bisect_left(L,L[i]+L[j],j)-j-1 # Code 2 

print(ans)
import bisect

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

import bisect

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

-        # ans+=bisect.bisect_left(L,L[i]+L[j])-j-1 -        ans += bisect.bisect_left(L, L[i] + L[j], j) - j - 1 +        ans += bisect.bisect_left(L, L[i] + L[j]) - j - 1  # Code 1 +        # ans+=bisect.bisect_left(L,L[i]+L[j],j)-j-1 # Code 2