program dm
    implicit none
    integer::N
    integer,allocatable,dimension(:)::A
    integer(16),allocatable,dimension(:)::nums
    integer::i
    integer(16)::S
    read*,N
    allocate(A(N),nums(N))
    nums=0
    read*,A
    do i=1,N
        nums(A(I))=nums(A(I))+1
    end do
    S=0
    do i=1,N
        S= S+(nums(i)*(nums(i)-1))/2
    end do
    do i=1,N
        print"(i0)",S-nums(A(i))+1
    end do
end program dm