program main
    implicit none
    integer(8) n, m, sum
    integer(8), allocatable, dimension(:) :: a, b
    integer(8) i,k

    read(*,*) n
    allocate(a(n))
    allocate(b(n))
    read(*,*) a

    b = 0

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

    sum = 0

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

    do k = 1, n
        if (b(a(k)) > 2) then
            write(*,*) sum - b(a(k))*(b(a(k))-1)/2 + (b(a(k))-1)*(b(a(k))-2)/2
        else if (b(a(k)) == 2) then
            write(*,*) sum - 1
        else
            write(*,*) sum
        end if
    end do


end program