program kadai
integer ::  n,i
integer(16)  ::  moto,ans
integer,allocatable  ::  x(:)
integer,allocatable  ::  List(:)

read(*,*) n
allocate(x(n))
allocate(List(n))
read(*,*) x
List=0

do i=1,n
    List(x(i)) = List(x(i)) + 1
end do
!write(*,*) List

moto=0
ans=0

do i=1,n
    if (List(i)>1) then
        moto=moto+List(i)*(List(i)-1)/2
    end if
end do

!write(*,*) n ,x
do i=1,n
    if (List(x(i))>1) then
        ans=moto+1-List(x(i))
    else
        ans=moto
    end if
    write(*,*) ans
end do


stop


end program kadai
