Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    import numpy as np
    from collections import Counter

    N = int(input())
    A = list(map(int,input().split()))
    c = Counter(A)

    tmp = np.array(list(c.values()))
    l1= tmp*(tmp-1)//2
    l2= (tmp-1)*((tmp-1)-1)//2
    S = np.sum(l1)

    for a in A:
        r = list(c).index(a)
        sum = S + l2[r] -l1[r]
        print(int(sum))

if __name__ == '__main__':
    main()


Fixed submission:
n=int(input())
A=list(map(int,input().split()))

import collections 
c=collections.Counter(A)
sum=0
for i in c:
  sum+=c[i]*(c[i]-1)//2  
for a in A:
  print(sum - c[a]*(c[a]-1)//2 + (c[a]-1)*(c[a]-2)//2)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    import numpy as np
    from collections import Counter

    N = int(input())
    A = list(map(int,input().split()))
    c = Counter(A)

    tmp = np.array(list(c.values()))
    l1= tmp*(tmp-1)//2
    l2= (tmp-1)*((tmp-1)-1)//2
    S = np.sum(l1)

    for a in A:
        r = list(c).index(a)
        sum = S + l2[r] -l1[r]
        print(int(sum))
        
if __name__ == '__main__':
    main()


Fixed submission:
n=int(input())
A=list(map(int,input().split()))

import collections 
c=collections.Counter(A)
sum=0
for i in c:
  sum+=c[i]*(c[i]-1)//2  
for a in A:
  print(sum - c[a]*(c[a]-1)//2 + (c[a]-1)*(c[a]-2)//2)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c = Counter(A)

for a in A:
    sum = 0
    for i in c:
        if a ==i:
            n =c[i]-1
        else:
            n=c[i]
        sum += n * (n - 1) // 2
    print(sum)



Fixed submission:
n=int(input())
A=list(map(int,input().split()))

import collections 
c=collections.Counter(A)
sum=0
for i in c:
  sum+=c[i]*(c[i]-1)//2  
for a in A:
  print(sum - c[a]*(c[a]-1)//2 + (c[a]-1)*(c[a]-2)//2)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    import numpy as np
    from collections import Counter

    N = int(input())
    A = list(map(int,input().split()))
    c = Counter(A)

    tmp = np.array(list(c.values()))
    l1= tmp*(tmp-1)//2
    l2= (tmp-1)*((tmp-1)-1)//2

    for a in A:
        r = list(c).index(a)
        sum = np.sum(l1) + l2[r] -l1[r]
        print(int(sum))
if __name__ == '__main__':
    main()


Fixed submission:
n=int(input())
A=list(map(int,input().split()))

import collections 
c=collections.Counter(A)
sum=0
for i in c:
  sum+=c[i]*(c[i]-1)//2  
for a in A:
  print(sum - c[a]*(c[a]-1)//2 + (c[a]-1)*(c[a]-2)//2)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c = Counter(A)

tmp = np.array(list(c.values()))
l1= tmp*(tmp-1)//2
l2= (tmp-1)*((tmp-1)-1)//2

for a in A:
    r = list(c).index(a)
    sum = np.sum(l1) + l2[r] -l1[r]
    print(int(sum))


Fixed submission:
n=int(input())
A=list(map(int,input().split()))

import collections 
c=collections.Counter(A)
sum=0
for i in c:
  sum+=c[i]*(c[i]-1)//2  
for a in A:
  print(sum - c[a]*(c[a]-1)//2 + (c[a]-1)*(c[a]-2)//2)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c = Counter(A)

tmp = []
for n in c:
    tmp.append(c[n])
tmp = np.array(tmp)
l1= tmp*(tmp-1)//2
l2= (tmp-1)*((tmp-1)-1)//2

for a in A:
    r = list(c).index(a)
    sum = np.sum(l1) + l2[r] -l1[r]
    print(int(sum))


Fixed submission:
n=int(input())
A=list(map(int,input().split()))

import collections 
c=collections.Counter(A)
sum=0
for i in c:
  sum+=c[i]*(c[i]-1)//2  
for a in A:
  print(sum - c[a]*(c[a]-1)//2 + (c[a]-1)*(c[a]-2)//2)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c = Counter(A)

NMAX=2*10**5

tmp = np.zeros((NMAX+1))
for n in c:
    tmp[n] = c[n]

l1= tmp*(tmp-1)//2
tmp -=1
l2= tmp*(tmp-1)//2

for a in A:
    sum = 0
    for i in c:
        if a ==i:
            sum += l2[i]
        else:
            sum += l1[i]
    print(int(sum))



Fixed submission:
n=int(input())
A=list(map(int,input().split()))

import collections 
c=collections.Counter(A)
sum=0
for i in c:
  sum+=c[i]*(c[i]-1)//2  
for a in A:
  print(sum - c[a]*(c[a]-1)//2 + (c[a]-1)*(c[a]-2)//2)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c = Counter(A)

NMAX=2*10**5

tmp = [0]*(NMAX+1)
tmp2 = [0]*(NMAX+1)
for n in c:
    k= c[n]-1
    tmp[n] = (c[n] * (c[n] - 1) // 2)
    tmp2[n] = (k * (k - 1) // 2)

for a in A:
    sum = 0
    for i in c:
        if a ==i:
            sum += tmp2[i]
        else:
            sum += tmp[i]
    print(sum)



Fixed submission:
n=int(input())
A=list(map(int,input().split()))

import collections 
c=collections.Counter(A)
sum=0
for i in c:
  sum+=c[i]*(c[i]-1)//2  
for a in A:
  print(sum - c[a]*(c[a]-1)//2 + (c[a]-1)*(c[a]-2)//2)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c = Counter(A)

NMAX=2*10**5

tmp = [0]*(NMAX+1)
for n in c:
    tmp[n] = (c[n] * (c[n] - 1) // 2)

for a in A:
    sum = 0
    for i in c:
        if a ==i:
            n =c[i]-1
            sum += n * (n - 1) // 2
        else:
            sum += tmp[i]

    print(sum)



Fixed submission:
n=int(input())
A=list(map(int,input().split()))

import collections 
c=collections.Counter(A)
sum=0
for i in c:
  sum+=c[i]*(c[i]-1)//2  
for a in A:
  print(sum - c[a]*(c[a]-1)//2 + (c[a]-1)*(c[a]-2)//2)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c = Counter(A)

for a in A:
    sum = 0
    for i in c:
        if a ==i:
            n =c[i]-1
        else:
            n=c[i]
        sum += n * (n - 1) // 2
    print(sum)



Fixed submission:
n=int(input())
A=list(map(int,input().split()))

import collections 
c=collections.Counter(A)
sum=0
for i in c:
  sum+=c[i]*(c[i]-1)//2  
for a in A:
  print(sum - c[a]*(c[a]-1)//2 + (c[a]-1)*(c[a]-2)//2)