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

    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


    csum = sum((cnt(:)*(cnt(:)-1))/2)
    

    do i=1, n
        ans(i) = csum - (cnt(a(i))-1)
    end do

    print*, ans(:)
end program main