import bisect
n=int(input())
l=[int(x) for x in input().rstrip().split()]
l.sort()

ans=0
comb=[]
ans=0
for i in range(n):
    for j in range(i+1,n):
        now=l[i]+l[j]
        ind=bisect.bisect_left(l,now)
        ans+=max(0,ind-j-1)

print(ans) import bisect bisect n=int(input()) n int(input()) int input() input int(x) for x in input().rstrip().split() for x in input().rstrip().split() x input().rstrip().split() ().rstrip().split ().rstrip() ().rstrip () input rstrip split for x in input().rstrip().split() int(x) int x l=[int(x) for x in input().rstrip().split()] l [int(x) for x in input().rstrip().split()] l.sort() l.sort l sort ans=0 ans 0 comb=[] comb [] ans=0 ans 0 for i in range(n):
    for j in range(i+1,n):
        now=l[i]+l[j]
        ind=bisect.bisect_left(l,now)
        ans+=max(0,ind-j-1) i range(n) range n for j in range(i+1,n):
        now=l[i]+l[j]
        ind=bisect.bisect_left(l,now)
        ans+=max(0,ind-j-1) j range(i+1,n) range i+1 i 1 n now=l[i]+l[j] now l[i]+l[j] l[i] l i l[j] l j ind=bisect.bisect_left(l,now) ind bisect.bisect_left(l,now) bisect.bisect_left bisect bisect_left l now ans+=max(0,ind-j-1) ans max(0,ind-j-1) max 0 ind-j-1 ind-j ind j 1 print(ans) print ans n=int(input()) int(input()) n ans+=max(0,ind-j-1) max(0,ind-j-1) ans ans=0 0 ans ind=bisect.bisect_left(l,now) bisect.bisect_left(l,now) ind l=[int(x) for x in input().rstrip().split()] [int(x) for x in input().rstrip().split()] l ans=0 0 ans comb=[] [] comb now=l[i]+l[j] l[i]+l[j] now
import bisect
n=int(input())
l=[int(x) for x in input().rstrip().split()]
l.sort()

ans=0
comb=[]
ans=0
for i in range(n):
    for j in range(i+1,n):
        now=l[i]+l[j]
        ind=bisect.bisect_left(l,now)
        ans+=max(0,ind-j-1)

print(ans)
