Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))

from collections import Counter
count = Counter(A)
 
s = 0
for c in list(count.values()):
    s += c*(c-1)/2

ans = 0
for a in A:
    n = A.count(a)
    ans = s - n*(n-1)/2 + (n-1)*(n-2)/2
    print(int(ans))

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

from collections import Counter
count = Counter(A)
 
s = 0
for c in list(count.values()):
    s += c*(c-1)/2

ans = 0
for a in A:
    n = count[a]
    ans = s - n*(n-1)/2 + (n-1)*(n-2)/2
    print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))

set_a  = set(A)
count_l = []
for a in set_a:
    count_l.append(A.count(a))
 
s = 0
for c in count_l:
    s += c*(c-1)/2

ans = 0
for a in A:
    n = A.count(a)
    ans = s - n*(n-1)/2 + (n-1)*(n-2)/2
    print(int(ans))

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

from collections import Counter
count = Counter(A)
 
s = 0
for c in list(count.values()):
    s += c*(c-1)/2

ans = 0
for a in A:
    n = count[a]
    ans = s - n*(n-1)/2 + (n-1)*(n-2)/2
    print(int(ans))

Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10**6)

n = int(input())
a_l = list(map(int, input().split()))

cnt = [0 for i in range(n)]

for i in range(n):
    cnt[a_l[i]]+=1
ans = 0

for a in cnt:
    ans += a*(a-1)/2
for i in range(n):
    print(int(ans - (cnt[a_l[i]]-1)))

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

from collections import Counter
count = Counter(A)
 
s = 0
for c in list(count.values()):
    s += c*(c-1)/2

ans = 0
for a in A:
    n = count[a]
    ans = s - n*(n-1)/2 + (n-1)*(n-2)/2
    print(int(ans))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a_l = list(map(int, input().split()))

cnt = [0 for i in range(n)]

for i in range(n):
    cnt[a_l[i]]+=1
ans = 0

for a in cnt:
    ans += a*(a-1)/2
for i in range(n):
    print(int(ans - (cnt[a_l[i]]-1)))

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

from collections import Counter
count = Counter(A)
 
s = 0
for c in list(count.values()):
    s += c*(c-1)/2

ans = 0
for a in A:
    n = count[a]
    ans = s - n*(n-1)/2 + (n-1)*(n-2)/2
    print(int(ans))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a_l = list(map(int, input().split()))

cnt = [0 for i in range(n)]

for i in range(n):
    cnt[a_l[i]]+=1
ans = 0

for a in cnt:
    ans += a*(a-1)/2
for i in range(n):
    print(ans - (cnt[a_l[i]]-1))

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

from collections import Counter
count = Counter(A)
 
s = 0
for c in list(count.values()):
    s += c*(c-1)/2

ans = 0
for a in A:
    n = count[a]
    ans = s - n*(n-1)/2 + (n-1)*(n-2)/2
    print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_l = list(map(int, input().split()))


for _ in range(n):
    ans = 0
    a = a_l.pop(0)
    a_set = set(a_l)
    for j in a_set:
        
        count = a_l.count(j)
        ans += count*(count-1)*(1/2)

    print(int(ans))
    a_l.append(a)


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

from collections import Counter
count = Counter(A)
 
s = 0
for c in list(count.values()):
    s += c*(c-1)/2

ans = 0
for a in A:
    n = count[a]
    ans = s - n*(n-1)/2 + (n-1)*(n-2)/2
    print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_l = list(map(int, input().split()))


for _ in range(n):
    ans = 0
    a = a_l.pop(0)
    a_set = set(a_l)
    for j in a_set:
        
        count = a_l.count(j)
        ans += count*(count-1)*(1/2)

    print(int(ans))
    a_l.append(a)


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

from collections import Counter
count = Counter(A)
 
s = 0
for c in list(count.values()):
    s += c*(c-1)/2

ans = 0
for a in A:
    n = count[a]
    ans = s - n*(n-1)/2 + (n-1)*(n-2)/2
    print(int(ans))