program main
  implicit none
  integer :: n, i, j, res
  integer, allocatable :: l(:)
  read (*, *) n
  allocate (l(n))
  read (*, *) l(:)
  res = 0
  call quicksort(l)
  do i = 1, n - 2
    do j = i + 2, n
      res = res + count_larger(l(i + 1:j - 1), l(j) - l(i))
    end do
  end do
  write (*, "(i0)") res
  contains

  integer function count_larger(ary, thres)
    integer, intent(in) :: ary(:), thres
    integer :: n, ma, mi, md, i
    n = size(ary)
    ma = n + 1  ! always larger than thres
    mi = 0  ! no more than thres
    do i = 1, 100
      md = mi + (ma - mi) / 2
      if (ary(md) > thres) then
        mi = md
      else
        ma = md
      end if
      if (ma - mi <= 1) exit
    end do
    count_larger = mi
  end function count_larger

  recursive subroutine quicksort(a)
    integer, intent(inout) :: a(:)
    integer :: pivot, i, j, k, tmp, n
    real(4) :: r
    n = size(a)
    if (n <= 1) return
    i = 1
    j = n
    call random_number(r)
    k = 1 + floor(r * n)
    k = max(1, min(k, n))
    pivot = a(k)
    do
      do while (.not. pivot <= a(i))
        i = i + 1
      end do
      do while (.not. a(j) <= pivot)
        j = j - 1
      end do
      if (i >= j) exit
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
      i = i + 1
      j = j - 1
    end do
    call quicksort(a(1:i - 1))
    call quicksort(a(j + 1:n))
  end subroutine quicksort
end program main
