Problem:
Score : 400 points

Problem Statement

We have N balls. The i-th ball has an integer A_i written on it.

For each k=1, 2, ..., N, solve the following problem and print the answer.

Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.

Constraints

3 \leq N \leq 2 \times 10^5

1 \leq A_i \leq N

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

For each k=1,2,...,N, print a line containing the answer.

Sample Input 1

5
1 1 2 1 2

Sample Output 1

2
2
3
2
3

Consider the case k=1 for example. The numbers written on the remaining balls are 1,2,1,2.

From these balls, there are two ways to choose two distinct balls so that the integers written on them are equal.

Thus, the answer for k=1 is 2.

Sample Input 2

4
1 2 3 4

Sample Output 2

0
0
0
0

No two balls have equal numbers written on them.

Sample Input 3

5
3 3 3 3 3

Sample Output 3

6
6
6
6
6

Any two balls have equal numbers written on them.

Sample Input 4

8
1 2 1 4 2 1 4 1

Sample Output 4

5
7
5
7
7
5
7
5

Solution in Ruby (2.3.3) (judge verdict: Accepted)

def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end


#class SegTree
#  attr_accessor:node,:n
#  def initialize(n,a)
#    @n=1
#    @n*=2 while @n<n
#    @node=array(2*@n,0)
#    n.times do|i|
#      @node[i+@n]=(a[i]-1)*a[i]/2
#    end
#    (@n-1).downto(1) do|i|
#      @node[i]=@node[i*2]+@node[i*2+1]
#    end
#  end
#
#  def update(i,x)
#    i+=@n
#    @node[i]=(x-1)*x/2
#    while i>1
#      i/=2
#      @node[i]=@node[i*2]+@node[i*2+1]
#    end
#  end
#
#  def getSum(l,r)
#    ret=0
#    l+=@n
#    r+=@n
#    while l<r
#      if l.odd?
#        ret+=@node[l]
#        l+=1
#      end
#
#      if r.odd?
#        r-=1
#        ret+=@node[r]
#      end
#      l/=2
#      r/=2
#    end
#    return ret
#  end
#end
#

N=gets.to_i
A=get_i
cnt=array(N+1,0)
A.each do|a|
  cnt[a]+=1
end
sum=0
cnt.each do|num|
  sum+=(num-1)*num/2
end
#st=SegTree.new(N+1,cnt)
#N.times do|i|
#  st.update(A[i],cnt[A[i]]-1)
#  puts st.getSum(0,N+2)
#  st.update(A[i],cnt[A[i]])
#end

N.times do|i|
  val1=(cnt[A[i]]-2)*(cnt[A[i]]-1)/2
  val2=(cnt[A[i]]-1)*cnt[A[i]]/2
  puts sum+val1-val2
end