program main
 implicit none
 integer N,i,j,p,k,flag
 integer,allocatable::L(:)
 
 read(*,*) N
 allocate(L(N))
 read(*,*) L
 
 call quicksort(L,1,N)
 
 k=0
 flag=0
 do i=N,2,-1
  do j=i-1,1,-1
   p = j/2
   do
    if(p==0) then
     flag = 1
     exit
    end if
    if(L(p) <= L(i) - L(j)) then
     flag = 0
     exit
    end if   
    p = p/2
   end do
   
   if(flag==0) then
    do
     p = p+1
     if(L(p) > L(i) - L(j)) exit
    end do
    if(j>p) k=k+(j-p)
   else
    k=k+j-1
   end if
  end do
 end do
 write(*,*) k
 
contains
recursive subroutine quicksort(a, first, last)
  implicit none
  integer a(*)
  integer first, last
  integer i, j
  integer x, t
 
  x = a( (first+last) / 2 )
  i = first
  j = last
  do
     do while (a(i) < x)
        i=i+1
     end do
     do while (x < a(j))
        j=j-1
     end do
     if (i >= j) exit
     t = a(i);  a(i) = a(j);  a(j) = t
     i=i+1
     j=j-1
  end do
  if (first < i - 1) call quicksort(a, first, i - 1)
  if (j + 1 < last)  call quicksort(a, j + 1, last)
end subroutine quicksort
end program main