Buggy python submission (verdict: Time Limit Exceeded):
import collections
def choose2(n):
    return n*(n-1)/2
sum1=0
sum2=0
N = int(input())
A = [int(N) for N in input().split()]
c = collections.Counter(A)
values, counts = zip(*c.most_common())
for i in range(len(counts)):
    sum1+=int(choose2(counts[i]))
for j in range(N):
    for k in range(len(counts)):
        if A[j] == values[k]:
            sum2+=int(sum1-choose2(counts[k])+choose2(counts[k]-1))
            print(sum2)
            sum2=0
            break

Fixed submission:
from collections import Counter
def choose2(n):
    return n*(n-1)/2
sum1=0
sum2=0
N = int(input())
A = [int(N) for N in input().split()]
S = Counter(A)
for i in  S.values():
    sum1+=int(choose2(i))
for j in range(N):
    sum2+=int(sum1-choose2(S[A[j]])+choose2(S[A[j]]-1))
    print(sum2)
    sum2=0

Buggy python submission (verdict: Time Limit Exceeded):
import collections
sum = 0
#Asum=[]
N = int(input())
A =  [int(N) for N in input().split()]
B = A.copy()
for i in range(N):
    B.pop(i)
    c = collections.Counter(B)
    values, counts = zip(*c.most_common())
    for j in range(len(counts)):
        if counts[j]>1:
            sum+=int(counts[j]*(counts[j]-1)/2)
        else:
            break
    B=A.copy()
    #Asum.append(sum)
    print(sum)
    sum=0
#for k in range(N):
    #print(Asum[k])

Fixed submission:
from collections import Counter
def choose2(n):
    return n*(n-1)/2
sum1=0
sum2=0
N = int(input())
A = [int(N) for N in input().split()]
S = Counter(A)
for i in  S.values():
    sum1+=int(choose2(i))
for j in range(N):
    sum2+=int(sum1-choose2(S[A[j]])+choose2(S[A[j]]-1))
    print(sum2)
    sum2=0

Buggy python submission (verdict: Time Limit Exceeded):
import collections
sum = 0
Asum=[]
N = int(input())
A =  [int(N) for N in input().split()]
B = A.copy()
for i in range(N):
    B.pop(i)
    c = collections.Counter(B)
    values, counts = zip(*c.most_common())
    for j in range(len(counts)):
        if counts[j]>1:
            sum+=int(counts[j]*(counts[j]-1)/2)
        else:
            break
    B=A.copy()
    Asum.append(int(sum))
    sum=0
for k in range(N):
    print(Asum[k])

Fixed submission:
from collections import Counter
def choose2(n):
    return n*(n-1)/2
sum1=0
sum2=0
N = int(input())
A = [int(N) for N in input().split()]
S = Counter(A)
for i in  S.values():
    sum1+=int(choose2(i))
for j in range(N):
    sum2+=int(sum1-choose2(S[A[j]])+choose2(S[A[j]]-1))
    print(sum2)
    sum2=0

Buggy python submission (verdict: Time Limit Exceeded):
import collections
sum = 0
Asum=[]
N = int(input())
A =  [int(N) for N in input().split()]
B = A.copy()
for i in range(N):
    B.pop(i)
    c = collections.Counter(B)
    values, counts = zip(*c.most_common())
    for j in range(len(counts)):
        sum+=int(counts[j]*(counts[j]-1)/2)
    B=A.copy()
    Asum.append(int(sum))
    sum=0
for k in range(N):
    print(Asum[k])

Fixed submission:
from collections import Counter
def choose2(n):
    return n*(n-1)/2
sum1=0
sum2=0
N = int(input())
A = [int(N) for N in input().split()]
S = Counter(A)
for i in  S.values():
    sum1+=int(choose2(i))
for j in range(N):
    sum2+=int(sum1-choose2(S[A[j]])+choose2(S[A[j]]-1))
    print(sum2)
    sum2=0