! 2019.10.20
! After contest
!
      program answer
      implicit none
      integer :: N
      integer,allocatable,dimension(:) :: L
      integer :: sorting
      integer,dimension(2) :: judging
      integer,dimension(2) :: threshold
      integer(8) :: ans
      integer :: i,j,k
      integer,external :: binary_search
!
      read(*,*) N
      allocate(L(N))
      read(*,*) (L(i),i=1,N)
! sorting L(i) [i=1,2,...] to ascending order
      call quicksort(N,L,1,N)
!
      ans = 0
! 
      do i=1,N-1
        do j=i+1,N
          judging(1) = L(j)-L(i)
          judging(2) = L(j)+L(i)
          threshold(1) = binary_search(N,L,judging(1))
          threshold(2) = binary_search(N,L,judging(2))
          do k=threshold(1),threshold(2)
            if(k == i .or. k == j) then
            else
              if(L(k) .gt. judging(1) .and. L(k) .lt. judging(2)) then
                ans = ans + 1
              end if
            end if
          end do
        end do
      end do
!
      write(*,*) ans/3
!
      end program answer
!
!-------------------------------------------------
      recursive subroutine quicksort(n,x,l,r)
!-------------------------------------------------
! Variables I/O
!-------------------------------------------------
! n     ...  the number of data (IN) : integer
! x(i)  ...  data (INOUT) : integer
! l     ...  the smallest label in a sorted region
!            (compute label)
! r     ...  the largest label in a sorted region
!            (compute label)
!-------------------------------------------------
! Variables (The others)
!-------------------------------------------------
! c     ...  the average of l and r : (l+r)/2
! ls    ...  the smallest label in a sorted region
!            (Input label)
! i     ...  the largest label in a sorted region
!            (Input label)
!-------------------------------------------------
! Contain
!-------------------------------------------------
! Subroutine : swap(a,b) : swaping a for b
!-------------------------------------------------
      implicit none
      integer,intent(in) :: n,l,r
      integer,dimension(n),intent(inout) :: x
      integer :: c,ls,i
!
      if(l < r) then
        c = (l+r) / 2 ! representative value
        call swap(x(l),x(c))
        ls = l
        do i=l+1,r
          if(x(i) < x(l)) then
            ls = ls + 1
            call swap(x(ls),x(i))
          end if
        end do
        call swap(x(ls),x(l))
        call quicksort(n,x,l,ls-1)
        call quicksort(n,x,ls+1,r)
      end if
      contains
!-------------------------------------------------
      subroutine swap(a,b)
!-------------------------------------------------
        integer,intent(inout) :: a,b
        integer :: w
        w=a
        a=b
        b=w
      end subroutine swap
      end subroutine quicksort
!
      function binary_search(n,x,key) result(res)
      implicit none
      integer :: n,key,res,i,l,r
      integer,dimension(n) :: x
      res = 0
      l = 1
      r = n
      do
        if(l>r) then
          res = l-1
          exit
        end if
        i = (l+r) / 2
        if(x(1) == key) then
          res = i
          exit
        end if
        if(x(i) < key) then
          l = i+1
        else
          r = i-1
        end if
      end do
      end function binary_search