implicit none

integer n,i,j,k,m
integer,allocatable,dimension(:) :: l
integer :: res=0


read(5,*) n
allocate(l(n))
read(5,*) l(1:n)


do i=1,n
 do j=i+1,n
  do k=j+1,n
   m=max(l(k),max(l(i),l(j)))
   if(m.lt.l(i)+l(j)+l(k)-m) then
   res=res+1
   endif
  enddo
  enddo
  enddo

write(6,*) res

end