Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
li = list(map(int, input().split()))
for k in range(N):
    buf = li[k]
    li[k], ans = -1, 0
    counter = Counter(li)
    for i in counter.most_common():
        cnt = i[1]
        ans += cnt * (cnt-1)
    print(ans//2)
    li[k] = buf

Fixed submission:
from collections import Counter
N, li = int(input()), list(map(int, input().split()))
cnt_dict, cnt_total = Counter(li), 0
for i in cnt_dict.items():
    cnt_total += i[1] * (i[1]-1) // 2
for k in range(N):
    buf = cnt_dict[li[k]]
    print(cnt_total - buf*(buf-1)//2 + (buf-1)*(buf-2)//2)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
li = list(map(int, input().split()))
for k in range(N):
    check_li, ans = li[:k]+li[k+1:], 0
    counter = Counter(check_li)
    for i in counter.most_common():
        cnt = i[1]
        ans += cnt * (cnt-1)
    print(ans//2)

Fixed submission:
from collections import Counter
N, li = int(input()), list(map(int, input().split()))
cnt_dict, cnt_total = Counter(li), 0
for i in cnt_dict.items():
    cnt_total += i[1] * (i[1]-1) // 2
for k in range(N):
    buf = cnt_dict[li[k]]
    print(cnt_total - buf*(buf-1)//2 + (buf-1)*(buf-2)//2)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
li = list(map(int, input().split()))
for k in range(N):
    check_li, ans = li[:k]+li[k+1:], 0
    counter = Counter(check_li)
    for i in counter.most_common():
        cnt = i[1]
        ans += cnt * (cnt-1) // 2
    print(ans)

Fixed submission:
from collections import Counter
N, li = int(input()), list(map(int, input().split()))
cnt_dict, cnt_total = Counter(li), 0
for i in cnt_dict.items():
    cnt_total += i[1] * (i[1]-1) // 2
for k in range(N):
    buf = cnt_dict[li[k]]
    print(cnt_total - buf*(buf-1)//2 + (buf-1)*(buf-2)//2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
li = list(map(int, input().split()))
for k in range(N):
    check_li, ans = li[:k]+li[k+1:], 0
    for i in list(set(check_li)):
        cnt = check_li.count(i)
        ans += cnt * (cnt-1) // 2
    print(ans)

Fixed submission:
from collections import Counter
N, li = int(input()), list(map(int, input().split()))
cnt_dict, cnt_total = Counter(li), 0
for i in cnt_dict.items():
    cnt_total += i[1] * (i[1]-1) // 2
for k in range(N):
    buf = cnt_dict[li[k]]
    print(cnt_total - buf*(buf-1)//2 + (buf-1)*(buf-2)//2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
li = list(map(int, input().split()))
for k in range(N):
    check_li, ans = li[:k]+li[k+1:], 0
    for i in list(set(check_li)):
        cnt = check_li.count(i)
        ans += cnt * (cnt-1) // 2
    print(ans)

Fixed submission:
from collections import Counter
N, li = int(input()), list(map(int, input().split()))
cnt_dict, cnt_total = Counter(li), 0
for i in cnt_dict.items():
    cnt_total += i[1] * (i[1]-1) // 2
for k in range(N):
    buf = cnt_dict[li[k]]
    print(cnt_total - buf*(buf-1)//2 + (buf-1)*(buf-2)//2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
li = list(map(int, input().split()))
for k in range(N):
    check_li, ans = li[:k]+li[k+1:], 0
    for i in range(1, N+1):
        ans += check_li.count(i) * (check_li.count(i)-1) // 2
    print(ans)

Fixed submission:
from collections import Counter
N, li = int(input()), list(map(int, input().split()))
cnt_dict, cnt_total = Counter(li), 0
for i in cnt_dict.items():
    cnt_total += i[1] * (i[1]-1) // 2
for k in range(N):
    buf = cnt_dict[li[k]]
    print(cnt_total - buf*(buf-1)//2 + (buf-1)*(buf-2)//2)