Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N=int(input())
A=[int(x) for x in input().rstrip().split()]
A_s=list(set(A))
A_count=[]
cnt=0

A_count=[A.count(A_s[x]) for x in range(len(A_s))]
# for x in range(len(A_s)):
#   i=A.count(A_s[x])
#   A_count.append(i)



for i in A_count:
  if 2<=i:
    cnt+=(i*(i-1))//2



# [print(cnt) if A_count[A_s.index(A[i])]==1 else print(cnt-A_count[A_s.index(A[i])]+1) for i in range(N)]

for i in A:
  x=A_count[A_s.index(i)]
  if x==1:
    print(cnt)
  else:
    print(cnt-x+1)

Fixed submission:
import collections
N=int(input())
A=[int(x) for x in input().rstrip().split()]
A_c=collections.Counter(A)
cnt=0

for i in A_c.values():
  cnt+=(i*(i-1))//2


for i in A:
  x=A_c[i]
  if x==1:
    print(cnt)
  else:
    print(cnt-x+1)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N=int(input())
A=[int(x) for x in input().rstrip().split()]
A_s=list(set(A))
A_count=[]
cnt=0

A_count=[A.count(A_s[x]) for x in range(len(A_s))]
# for x in range(len(A_s)):
#   i=A.count(A_s[x])
#   A_count.append(i)



for i in A_count:
  if 2<=i:
    cnt+=(i*(i-1))//2



[print(cnt) if A_count[A_s.index(A[i])]==1 else print(cnt-A_count[A_s.index(A[i])]+1) for i in range(N)]

# for i in range(N):
#   x=A_count[A_s.index(A[i])]
#   if x==1:
#     print(cnt)
#   else:
#     print(cnt-x+1)

Fixed submission:
import collections
N=int(input())
A=[int(x) for x in input().rstrip().split()]
A_c=collections.Counter(A)
cnt=0

for i in A_c.values():
  cnt+=(i*(i-1))//2


for i in A:
  x=A_c[i]
  if x==1:
    print(cnt)
  else:
    print(cnt-x+1)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N=int(input())
A=[int(x) for x in input().rstrip().split()]
A_s=list(set(A))
A_count=[]
cnt=0

A_count=[A.count(A_s[x]) for x in range(len(A_s))]
# for x in range(len(A_s)):
#   i=A.count(A_s[x])
#   A_count.append(i)



for i in A_count:
  if 2<=i:
    cnt+=(i*(i-1))//2



# [print(cnt) if A_count[A_s.index(A[i])]==1 else print(cnt-A_count[A_s.index(A[i])]+1) for i in range(N)]

for i in range(N):
  x=A_count[A_s.index(A[i])]
  if x==1:
    print(cnt)
  else:
    print(cnt-x+1)

Fixed submission:
import collections
N=int(input())
A=[int(x) for x in input().rstrip().split()]
A_c=collections.Counter(A)
cnt=0

for i in A_c.values():
  cnt+=(i*(i-1))//2


for i in A:
  x=A_c[i]
  if x==1:
    print(cnt)
  else:
    print(cnt-x+1)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N=int(input())
A=[int(x) for x in input().rstrip().split()]
A_s=list(set(A))
A_count=[]
cnt=0

for x in range(len(A_s)):
  i=A.count(A_s[x])
  A_count.append(i)

  if 2<=i:
    cnt+=(i*(i-1))//2



[print(cnt) if A_count[A_s.index(A[i])]==1 else print(cnt-A_count[A_s.index(A[i])]+1) for i in range(N)]

# for i in range(N):
#   x=A_count[A_s.index(A[i])]
#   if x==1:
#     print(cnt)
#   else:
#     print(cnt-x+1)

Fixed submission:
import collections
N=int(input())
A=[int(x) for x in input().rstrip().split()]
A_c=collections.Counter(A)
cnt=0

for i in A_c.values():
  cnt+=(i*(i-1))//2


for i in A:
  x=A_c[i]
  if x==1:
    print(cnt)
  else:
    print(cnt-x+1)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N=int(input())
A=[int(x) for x in input().rstrip().split()]
A_s=list(set(A))
A_count=[]
cnt=0

for x in range(len(A_s)):
  i=A.count(A_s[x])
  A_count.append(i)

  if 2<=i:
    cnt+=(i*(i-1))//2


for i in range(N):
  x=A_count[A_s.index(A[i])]
  if x==1:
    print(cnt)
  else:
    print(cnt-x+1)

Fixed submission:
import collections
N=int(input())
A=[int(x) for x in input().rstrip().split()]
A_c=collections.Counter(A)
cnt=0

for i in A_c.values():
  cnt+=(i*(i-1))//2


for i in A:
  x=A_c[i]
  if x==1:
    print(cnt)
  else:
    print(cnt-x+1)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N=int(input())
A=[int(x) for x in input().rstrip().split()]
A_s=list(set(A))
A_count=[]
cnt=0

for x in range(len(A_s)):
  i=A.count(A_s[x])
  A_count.append(i)

  if 2<=i:
    cnt+=(i*(i-1))//2


for i in range(N):
  if A_count[A_s.index(A[i])]==1:
    print(cnt)
  else:
    print(cnt-A_count[A_s.index(A[i])]+1)

Fixed submission:
import collections
N=int(input())
A=[int(x) for x in input().rstrip().split()]
A_c=collections.Counter(A)
cnt=0

for i in A_c.values():
  cnt+=(i*(i-1))//2


for i in A:
  x=A_c[i]
  if x==1:
    print(cnt)
  else:
    print(cnt-x+1)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N=int(input())
A=[int(x) for x in input().rstrip().split()]
A_s=list(set(A))
A_count=[]
cnt=0

for i in range(len(A_s)):
  A_count.append(A.count(A_s[i]))


for i in A_count:
  if 2<=i:
    cnt+=(i*(i-1))//2




for i in range(N):
  if A_count[A_s.index(A[i])]==1:
    print(cnt)
  else:
    print(cnt-A_count[A_s.index(A[i])]+1)


 










Fixed submission:
import collections
N=int(input())
A=[int(x) for x in input().rstrip().split()]
A_c=collections.Counter(A)
cnt=0

for i in A_c.values():
  cnt+=(i*(i-1))//2


for i in A:
  x=A_c[i]
  if x==1:
    print(cnt)
  else:
    print(cnt-x+1)