program B175
    implicit none
    integer(8) :: N
    integer(8), allocatable, dimension(:) :: L
    integer(8) :: i, j, k, ans

    read(5,*) N
    allocate(L(N))
    read(5,*) (L(i), i = 1, N)

    ans = 0
    do i = 1, N-2
        do j = i+1, N-1
            do k = j+1, N
                call judge(L(i),L(j),L(k),ans)
            end do
        end do
    end do
    
    write(6,*) ans
    

    stop
end program B175

subroutine judge(L1,L2,L3,ans)
    implicit none
    integer(8) :: L1, L2, L3, ans, a1, a2, a3, i
    integer(8), dimension(3) :: a
    
    a(1) = L1
    a(2) = L2
    a(3) = L3

    a1 = maxval(a)
    a3 = minval(a)

    do i = 1, 3
        if (a(i) == a1) then
            a(i) = 0
        else if (a(i) == a3) then
            a(i) = 0
        end if
    end do

    a2 = maxval(a)

    if (a1 < a2 + a3) then
        ans = ans + 1
    end if

    return
end subroutine