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

Al = 0
cnt = 0
def solution(N,A,B,Al,cnt):
  for a in B:
      cnt = A.count(a)
      Al +=  cnt*(cnt-1)//2

  for k in range(N):
      cnt = A.count(A[k])
      print(Al - cnt +1)
solution(N,A,B,Al,cnt)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = set(A)

from collections import Counter
cnt_A = Counter(A)

All = 0
cnt = 0
for a in B:
    cnt = cnt_A[a]
    All +=  cnt*(cnt-1)//2

for k in range(N):
    ans_k = 0
    cnt = cnt_A[A[k]]
    ans_k = cnt - 1
    Ans = All - ans_k
    print(Ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = set(A)

Al = 0
cnt = 0
def solution(N,A,B,Al,cnt):
  for a in B:
      cnt = A.count(a)
      Al +=  cnt*(cnt-1)//2

  for k in range(N):
      cnt = A.count(A[k])
      print(Al - cnt +1)
solution(N,A,B,Al,cnt):


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = set(A)

from collections import Counter
cnt_A = Counter(A)

All = 0
cnt = 0
for a in B:
    cnt = cnt_A[a]
    All +=  cnt*(cnt-1)//2

for k in range(N):
    ans_k = 0
    cnt = cnt_A[A[k]]
    ans_k = cnt - 1
    Ans = All - ans_k
    print(Ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = set(A)

All = 0
cnt = 0
def solution(N,A,B,All,cnt):
  for a in B:
      cnt = A.count(a)
      All +=  cnt*(cnt-1)//2

  for k in range(N):
      cnt = A.count(A[k])
      print(All - cnt +1)
solution(N,A,B,All,cnt):

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = set(A)

from collections import Counter
cnt_A = Counter(A)

All = 0
cnt = 0
for a in B:
    cnt = cnt_A[a]
    All +=  cnt*(cnt-1)//2

for k in range(N):
    ans_k = 0
    cnt = cnt_A[A[k]]
    ans_k = cnt - 1
    Ans = All - ans_k
    print(Ans)

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

All = 0
cnt = 0
for a in B:
    cnt = A.count(a)
    All +=  cnt*(cnt-1)//2

for k in range(N):
    ans_k = 0
    cnt = A.count(A[k])
    ans_k = cnt - 1
    Ans = All - ans_k
    print(Ans)
    










Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = set(A)

from collections import Counter
cnt_A = Counter(A)

All = 0
cnt = 0
for a in B:
    cnt = cnt_A[a]
    All +=  cnt*(cnt-1)//2

for k in range(N):
    ans_k = 0
    cnt = cnt_A[A[k]]
    ans_k = cnt - 1
    Ans = All - ans_k
    print(Ans)

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

def main(N,A,B):
    for k in range(N):
        ans_k = 0
        rem_A = A[k]
        A.remove(rem_A)
        for n in B:
            cnt = A.count(n)
            ans_k += cnt*(cnt-1)//2
        A.insert(k,rem_A)
        print(ans_k)

main(N,A,B)




Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = set(A)

from collections import Counter
cnt_A = Counter(A)

All = 0
cnt = 0
for a in B:
    cnt = cnt_A[a]
    All +=  cnt*(cnt-1)//2

for k in range(N):
    ans_k = 0
    cnt = cnt_A[A[k]]
    ans_k = cnt - 1
    Ans = All - ans_k
    print(Ans)

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

for k in range(N):
    ans_k = 0
    rem_A = A[k]
    A.remove(rem_A)
    for n in B:
        cnt = A.count(n)
        ans_k += cnt*(cnt-1)//2
    A.insert(k,rem_A)
    print(ans_k)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = set(A)

from collections import Counter
cnt_A = Counter(A)

All = 0
cnt = 0
for a in B:
    cnt = cnt_A[a]
    All +=  cnt*(cnt-1)//2

for k in range(N):
    ans_k = 0
    cnt = cnt_A[A[k]]
    ans_k = cnt - 1
    Ans = All - ans_k
    print(Ans)