import bisect
import collections
N=int(input())
L=list(map(int,input().split()))
L.sort()
c = collections.Counter(L)
#print(L)
 
#b-a < c < a+b

#a<=b<=c
ans=0
L_a=L[:N-2]
for i,a in enumerate(L_a):
    L_b=L[i+1:N-1]
    for j,b in enumerate(L_b,start=i+1):
        x=bisect.bisect(L[j+1:],a+b)
        ans+=x
        if a+b==L[j+x]:
            #print(a,b,L[j+x])
            ans-=c[a+b]
        #print(i,a,j,b,x,N-j-1,L[j+1:])
print(ans) import bisect bisect import collections collections N=int(input()) N int(input()) int input() input L=list(map(int,input().split())) L list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split L.sort() L.sort L sort c = collections.Counter(L) c collections.Counter(L) collections.Counter collections Counter L ans=0 ans 0 L_a=L[:N-2] L_a L[:N-2] L :N-2 N-2 N 2 for i,a in enumerate(L_a):
    L_b=L[i+1:N-1]
    for j,b in enumerate(L_b,start=i+1):
        x=bisect.bisect(L[j+1:],a+b)
        ans+=x
        if a+b==L[j+x]:
            #print(a,b,L[j+x])
            ans-=c[a+b]
        #print(i,a,j,b,x,N-j-1,L[j+1:]) i a enumerate(L_a) enumerate L_a L_b=L[i+1:N-1] L_b L[i+1:N-1] L i+1:N-1 i+1 i 1 N-1 N 1 for j,b in enumerate(L_b,start=i+1):
        x=bisect.bisect(L[j+1:],a+b)
        ans+=x
        if a+b==L[j+x]:
            #print(a,b,L[j+x])
            ans-=c[a+b]
        #print(i,a,j,b,x,N-j-1,L[j+1:]) j b enumerate(L_b,start=i+1) enumerate L_b start=i+1 start i+1 i 1 x=bisect.bisect(L[j+1:],a+b) x bisect.bisect(L[j+1:],a+b) bisect.bisect bisect bisect L[j+1:] L j+1: j+1 j 1 a+b a b ans+=x ans x if a+b==L[j+x]:
            #print(a,b,L[j+x])
            ans-=c[a+b]
        #print(i,a,j,b,x,N-j-1,L[j+1:]) a+b==L[j+x] a+b a b L[j+x] L j+x j x ans-=c[a+b] ans c[a+b] c a+b a b print(ans) print ans L_b=L[i+1:N-1] L[i+1:N-1] L_b c = collections.Counter(L) collections.Counter(L) c ans=0 0 ans ans+=x x ans N=int(input()) int(input()) N x=bisect.bisect(L[j+1:],a+b) bisect.bisect(L[j+1:],a+b) x L_a=L[:N-2] L[:N-2] L_a ans-=c[a+b] c[a+b] ans L=list(map(int,input().split())) list(map(int,input().split())) L
import bisect
import collections
N=int(input())
L=list(map(int,input().split()))
L.sort()
c = collections.Counter(L)
#print(L)
 
#b-a < c < a+b

#a<=b<=c
ans=0
L_a=L[:N-2]
for i,a in enumerate(L_a):
    L_b=L[i+1:N-1]
    for j,b in enumerate(L_b,start=i+1):
        x=bisect.bisect(L[j+1:],a+b)
        ans+=x
        if a+b==L[j+x]:
            #print(a,b,L[j+x])
            ans-=c[a+b]
        #print(i,a,j,b,x,N-j-1,L[j+1:])
print(ans)