program main
    implicit none
    integer(4):: n
    integer(4),allocatable:: a(:), cnt(:), ans(:)
    integer(4):: i,j, tn

    read*, n
    allocate(a(n), cnt(n), ans(n))
    read*, a(:)

    cnt(:) = 0

    do i=1, n
        cnt(a(i)) =cnt(a(i)) + 1
    end do

    ans(:) = 0
    do i=1,n    
        do j=1,n
            if (j == a(i)) then
                tn = cnt(j)-1
            else
                tn = cnt(j)
            end if

            ans(i) = ans(i) + tn*(tn-1)/2

        end do
        
    end do

    print*, ans(:)
end program main