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):
    res=l[i]+l[j]
    ans+=bisect.bisect_left(l,res)-1-j
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):
    res=l[i]+l[j]
    ans+=bisect.bisect_left(l,res)-1-j i range(n-2) range n-2 n 2 for j in range(i+1,n-1):
    res=l[i]+l[j]
    ans+=bisect.bisect_left(l,res)-1-j j range(i+1,n-1) range i+1 i 1 n-1 n 1 res=l[i]+l[j] res l[i]+l[j] l[i] l i l[j] l j ans+=bisect.bisect_left(l,res)-1-j ans bisect.bisect_left(l,res)-1-j bisect.bisect_left(l,res)-1 bisect.bisect_left(l,res) bisect.bisect_left bisect bisect_left l res 1 j print(ans) print ans ans+=bisect.bisect_left(l,res)-1-j bisect.bisect_left(l,res)-1-j ans l=list(map(int,input().split())) list(map(int,input().split())) l res=l[i]+l[j] l[i]+l[j] res n=int(input()) int(input()) n ans=0 0 ans
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):
    res=l[i]+l[j]
    ans+=bisect.bisect_left(l,res)-1-j
print(ans)