Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
d = [0]*(n+1)
count = 0
for el in set(a):
    temp = d[el] = a.count(el)
    count += temp*(temp-1)
count //= 2
for el in a:
    print(count - d[el] + 1)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
counter = Counter(a)
d = [0]*(n+1)
count = 0
for el, cnt in counter.most_common():
    d[el] = cnt
    count += cnt*(cnt-1)
count //= 2
for el in a:
    print(count - d[el] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
work = set(a)
d = [0]*(n+1)
count = 0
for el in work:
    temp = d[el] = a.count(el)
    count += temp*(temp-1)
count //= 2
for el in a:
    print(count - d[el] + 1)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
counter = Counter(a)
d = [0]*(n+1)
count = 0
for el, cnt in counter.most_common():
    d[el] = cnt
    count += cnt*(cnt-1)
count //= 2
for el in a:
    print(count - d[el] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
d = [0]*(n+1)
count = 0
for el in a:
    temp = d[el]
    if temp == 0:
        temp = a.count(el)
        d[el] = temp
        count += temp*(temp-1)
count //= 2
for el in a:
    print(count - d[el] + 1)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
counter = Counter(a)
d = [0]*(n+1)
count = 0
for el, cnt in counter.most_common():
    d[el] = cnt
    count += cnt*(cnt-1)
count //= 2
for el in a:
    print(count - d[el] + 1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
d = [0]*n
count = 0
for el in a:
    temp = d[el]
    if temp == 0:
        temp = a.count(el)
        d[el] = temp
    count += temp-1
count //= 2
for el in a:
    print(count - d[el] + 1)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
counter = Counter(a)
d = [0]*(n+1)
count = 0
for el, cnt in counter.most_common():
    d[el] = cnt
    count += cnt*(cnt-1)
count //= 2
for el in a:
    print(count - d[el] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
d = []
count = 0
for el in a:
    temp = a.count(el)
    count += temp-1
    d.append(temp)
count //= 2
for el in d:
    print(count - el + 1)


Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
counter = Counter(a)
d = [0]*(n+1)
count = 0
for el, cnt in counter.most_common():
    d[el] = cnt
    count += cnt*(cnt-1)
count //= 2
for el in a:
    print(count - d[el] + 1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
d = [0]*n
count = 0
for el in a:
    temp = a.count(el)
    count += temp-1
    d[el] = temp
count //= 2
for el in a:
    print(count - d[el]+1)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
counter = Counter(a)
d = [0]*(n+1)
count = 0
for el, cnt in counter.most_common():
    d[el] = cnt
    count += cnt*(cnt-1)
count //= 2
for el in a:
    print(count - d[el] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
d = dict()
count = 0
for el in a:
    temp = a.count(el)
    count += temp-1
    d[str(el)] = temp
count //= 2
for el in a:
    print(count - d[str(el)]+1)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
counter = Counter(a)
d = [0]*(n+1)
count = 0
for el, cnt in counter.most_common():
    d[el] = cnt
    count += cnt*(cnt-1)
count //= 2
for el in a:
    print(count - d[el] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
d = dict()
count = 0
for el in a:
    temp = a.count(el)
    count += temp-1
    d[str(el)] = temp
count //= 2
for el in a:
    print(count - d[str(el)]+1)


Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
counter = Counter(a)
d = [0]*(n+1)
count = 0
for el, cnt in counter.most_common():
    d[el] = cnt
    count += cnt*(cnt-1)
count //= 2
for el in a:
    print(count - d[el] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
count = 0
for el in a:
    count += a.count(el)-1
count //= 2
for el in a:
    print(count - a.count(el)+1)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
counter = Counter(a)
d = [0]*(n+1)
count = 0
for el, cnt in counter.most_common():
    d[el] = cnt
    count += cnt*(cnt-1)
count //= 2
for el in a:
    print(count - d[el] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
count = 0
L = len(a)
for el in a:
    count += a.count(el)-1
count //= 2
for el in a:
    print(count - a.count(el)+1)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
counter = Counter(a)
d = [0]*(n+1)
count = 0
for el, cnt in counter.most_common():
    d[el] = cnt
    count += cnt*(cnt-1)
count //= 2
for el in a:
    print(count - d[el] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
count = 0
for i in range(len(a)):
    count += a.count(a[i])-1
count //= 2
for i in range(len(a)):
    print(count - a.count(a[i])+1)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
counter = Counter(a)
d = [0]*(n+1)
count = 0
for el, cnt in counter.most_common():
    d[el] = cnt
    count += cnt*(cnt-1)
count //= 2
for el in a:
    print(count - d[el] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
count = 0
for i in range(len(a)):
    count += a[i+1:].count(a[i])
for i in range(len(a)):
    print(count - a.count(a[i])+1)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
counter = Counter(a)
d = [0]*(n+1)
count = 0
for el, cnt in counter.most_common():
    d[el] = cnt
    count += cnt*(cnt-1)
count //= 2
for el in a:
    print(count - d[el] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(n)]
for k in a:
    b[k-1] += 1
for k in a:
    b[k-1] -= 1
    result = 0
    for el in b:
        result += el*(el-1)//2
    print(result)
    b[k-1] += 1

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
counter = Counter(a)
d = [0]*(n+1)
count = 0
for el, cnt in counter.most_common():
    d[el] = cnt
    count += cnt*(cnt-1)
count //= 2
for el in a:
    print(count - d[el] + 1)