Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
b = Counter(a)
c = b.most_common()
values, counts = zip(*b.most_common())
d = (counts)
ans = 0

for j in range(len(d)):
    f = d[j]
    if f > 1:
        ans = ans + (f*(f - 1)/2)

for i in range(n):
    g = a[i]
    gc = a.count(g)
    tem = ans - gc + 1
    print(int(tem))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
ans = 0

for i in range(n):
    b[a[i] - 1] += 1

for i in range(n):
    ans += b[i]*(b[i] - 1)//2

for i in range(n):
    print(ans - b[a[i] -1] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
import collections

n = int(input())
a = list(map(int, input().split()))
b = collections.Counter(a)
c = b.most_common()
values, counts = zip(*b.most_common())
d = (counts)
ans = 0

for j in range(len(d)):
    f = d[j]
    if f > 1:
        ans = ans + (f*(f - 1)/2)

for i in range(n):
    g = a[i]
    gc = a.count(g)
    tem = ans - gc + 1
    print(int(tem))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
ans = 0

for i in range(n):
    b[a[i] - 1] += 1

for i in range(n):
    ans += b[i]*(b[i] - 1)//2

for i in range(n):
    print(ans - b[a[i] -1] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
import collections

n = int(input())
a = list(map(int, input().split()))
b = collections.Counter(a)
c = b.most_common()
values, counts = zip(*b.most_common())
d = (counts)
ans = 0

for j in range(len(d)):
    f = d[j]
    ans = ans + (f*(f - 1)/2)

for i in range(n):
    g = a[i]
    gc = a.count(g)
    tem = ans - gc + 1
    print(int(tem))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
ans = 0

for i in range(n):
    b[a[i] - 1] += 1

for i in range(n):
    ans += b[i]*(b[i] - 1)//2

for i in range(n):
    print(ans - b[a[i] -1] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
import collections

n = int(input())
a = list(map(int, input().split()))
ans = 0

for i in range(n):
    b = copy.copy(a)
    del b[i]
    c = collections.Counter(b)
    d = c.most_common()
    values, counts = zip(*c.most_common())
    e = (counts)
    for j in range(len(e)):
        f = e[j]
        ans = ans + (f*(f - 1)/2)
    print(int(ans))
    ans = 0

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
ans = 0

for i in range(n):
    b[a[i] - 1] += 1

for i in range(n):
    ans += b[i]*(b[i] - 1)//2

for i in range(n):
    print(ans - b[a[i] -1] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
import collections

n = int(input())
a = list(map(int, input().split()))
ans = 0

for i in range(n):
    b = copy.copy(a)
    del b[i]
    c = collections.Counter(b)
    d = c.most_common()
    values, counts = zip(*c.most_common())
    e = (counts)
    for j in range(len(e)):
        f = e[j]
        ans = ans + (f*(f - 1)/2)
    print(int(ans))
    ans = 0

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
ans = 0

for i in range(n):
    b[a[i] - 1] += 1

for i in range(n):
    ans += b[i]*(b[i] - 1)//2

for i in range(n):
    print(ans - b[a[i] -1] + 1)