program triangle
    implicit none
    integer :: n, i, j, k, cnt = 0, t
    integer,allocatable :: l(:)
    read *, n
    allocate(l(n))
    read *, l(1:n)
    do i = 1, n-1
        do j = 1, n
            if(l(i) .gt. l(j))then
                t = l(i)
                l(i) = l(j)
                l(j) = t
            end if
        end do
    end do
    do i = 1, n-2
        do j = i+1, n-1
            do k = j+1, n
                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
                    cnt = cnt+n-k+1
                    exit
                end if
            end do
        end do
    end do
    print *, cnt
end program