integer :: n,i,j,k,ans = 0
integer, allocatable :: l(:)
read*, n
allocate( l(n) )
read(*,*) l
do i = 2, n
    do j = i-1, 2, -1
        do k = j-1, 1, -1
            if((l(i)+l(j)).gt.l(k).and.(l(j)+l(k)).gt.l(i).and.(l(k)+l(i)).gt.l(j)) then
                ans = ans + 1
            end if
        end do
    end do
end do
print*, ans
end