import bisect

n=int(input())
l=list(map(int,input().split()))

l.sort()
ans=0

for i in range(n-2):
  for j in range(i+1,n-1):
    a=l[i]+l[j]
    b=l[j]-l[i]
    
    x=bisect.bisect_right(l,b)
    y=bisect.bisect_left(l,a)-1
    X=max(j+1,x)
    if y-X+1>0:
      ans+=y-X+1
      
print(ans) import bisect bisect 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 ans=0 ans 0 for i in range(n-2):
  for j in range(i+1,n-1):
    a=l[i]+l[j]
    b=l[j]-l[i]
    
    x=bisect.bisect_right(l,b)
    y=bisect.bisect_left(l,a)-1
    X=max(j+1,x)
    if y-X+1>0:
      ans+=y-X+1
       i range(n-2) range n-2 n 2 for j in range(i+1,n-1):
    a=l[i]+l[j]
    b=l[j]-l[i]
    
    x=bisect.bisect_right(l,b)
    y=bisect.bisect_left(l,a)-1
    X=max(j+1,x)
    if y-X+1>0:
      ans+=y-X+1
       j range(i+1,n-1) range i+1 i 1 n-1 n 1 a=l[i]+l[j] a l[i]+l[j] l[i] l i l[j] l j b=l[j]-l[i] b l[j]-l[i] l[j] l j l[i] l i x=bisect.bisect_right(l,b) x bisect.bisect_right(l,b) bisect.bisect_right bisect bisect_right l b y=bisect.bisect_left(l,a)-1 y bisect.bisect_left(l,a)-1 bisect.bisect_left(l,a) bisect.bisect_left bisect bisect_left l a 1 X=max(j+1,x) X max(j+1,x) max j+1 j 1 x if y-X+1>0:
      ans+=y-X+1
       y-X+1>0 y-X+1 y-X y X 1 0 ans+=y-X+1 ans y-X+1 y-X y X 1 print(ans) print ans X=max(j+1,x) max(j+1,x) X a=l[i]+l[j] l[i]+l[j] a y=bisect.bisect_left(l,a)-1 bisect.bisect_left(l,a)-1 y ans+=y-X+1 y-X+1 ans l=list(map(int,input().split())) list(map(int,input().split())) l ans=0 0 ans n=int(input()) int(input()) n b=l[j]-l[i] l[j]-l[i] b x=bisect.bisect_right(l,b) bisect.bisect_right(l,b) x
import bisect

n=int(input())
l=list(map(int,input().split()))

l.sort()
ans=0

for i in range(n-2):
  for j in range(i+1,n-1):
    a=l[i]+l[j]
    b=l[j]-l[i]
    
    x=bisect.bisect_right(l,b)
    y=bisect.bisect_left(l,a)-1
    X=max(j+1,x)
    if y-X+1>0:
      ans+=y-X+1
      
print(ans)