# D - Triangles
import bisect

N=int(input())
Li=list(map(int,input().split()))
Li.sort()

ans=0

for i in range(N):
    for j in range (i+1,N):
        a=Li[i]+Li[j]
        t=bisect.bisect_left(Li,a)
        ans+=t-(j+1)

print(ans) import bisect bisect N=int(input()) N int(input()) int input() input Li=list(map(int,input().split())) Li list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split Li.sort() Li.sort Li sort ans=0 ans 0 for i in range(N):
    for j in range (i+1,N):
        a=Li[i]+Li[j]
        t=bisect.bisect_left(Li,a)
        ans+=t-(j+1) i range(N) range N for j in range (i+1,N):
        a=Li[i]+Li[j]
        t=bisect.bisect_left(Li,a)
        ans+=t-(j+1) j range (i+1,N) range i+1 i 1 N a=Li[i]+Li[j] a Li[i]+Li[j] Li[i] Li i Li[j] Li j t=bisect.bisect_left(Li,a) t bisect.bisect_left(Li,a) bisect.bisect_left bisect bisect_left Li a ans+=t-(j+1) ans t-(j+1) t j+1 j 1 print(ans) print ans N=int(input()) int(input()) N ans+=t-(j+1) t-(j+1) ans ans=0 0 ans t=bisect.bisect_left(Li,a) bisect.bisect_left(Li,a) t Li=list(map(int,input().split())) list(map(int,input().split())) Li a=Li[i]+Li[j] Li[i]+Li[j] a
# D - Triangles
import bisect

N=int(input())
Li=list(map(int,input().split()))
Li.sort()

ans=0

for i in range(N):
    for j in range (i+1,N):
        a=Li[i]+Li[j]
        t=bisect.bisect_left(Li,a)
        ans+=t-(j+1)

print(ans)
