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

L=0
C=[]
for i in range(N):
    C.append(A.count(i+1))
    L+=int(C[i]*(C[i]-1)/2)
    
for i in A:
    print(L-C[i-1]+1)

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

L=0
C=[0]*N

for i in range(N):
    C[A[i]-1]+=1

for i in range(N):
    L+=int(C[i]*(C[i]-1)/2)
    
for i in A:
    print(L-C[i-1]+1)

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

L=0
C=[]
for i in range(N):
    C.append(A.count(i+1))
    L+=int(C[i]*(C[i]-1)/2)
    
for i in range(N):
    print(L-C[A[i]-1]+1)

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

L=0
C=[0]*N

for i in range(N):
    C[A[i]-1]+=1

for i in range(N):
    L+=int(C[i]*(C[i]-1)/2)
    
for i in A:
    print(L-C[i-1]+1)

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

L=0
C=[]
for i in range(N):
    C.append(A.count(i))
    L+=int(C[i]*(C[i]-1)/2)
    
for i in range(N):
    print(L-C[A[i]]+1)

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

L=0
C=[0]*N

for i in range(N):
    C[A[i]-1]+=1

for i in range(N):
    L+=int(C[i]*(C[i]-1)/2)
    
for i in A:
    print(L-C[i-1]+1)

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

A0=sorted(A)
i=0
L=0
while i<N:
    C=A0.count(A0[i])
    L+=int(C*(C-1)/2)
    i+=C

for i in range(N):
    L0=A.count(A[i])
    print(L-L0+1)

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

L=0
C=[0]*N

for i in range(N):
    C[A[i]-1]+=1

for i in range(N):
    L+=int(C[i]*(C[i]-1)/2)
    
for i in A:
    print(L-C[i-1]+1)

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

A0=sorted(A)
i=0
L=0
while i<N:
    C=A0.count(A0[i])
    L+=int(C*(C-1)/2)
    i+=C

for i in range(N):
    L0=A.count(A[i])
    print(L-L0+1)

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

L=0
C=[0]*N

for i in range(N):
    C[A[i]-1]+=1

for i in range(N):
    L+=int(C[i]*(C[i]-1)/2)
    
for i in A:
    print(L-C[i-1]+1)

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

for i in range(N):
    A0=A.copy()
    A0.pop(i)
    A0=sorted(A0)
    
    ii=0
    C=0
    L=0
    while ii<N-1:
        C=A0.count(A0[ii])
        ii+=C
        L=int(C*(C-1)/2)+L
    print(L)

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

L=0
C=[0]*N

for i in range(N):
    C[A[i]-1]+=1

for i in range(N):
    L+=int(C[i]*(C[i]-1)/2)
    
for i in A:
    print(L-C[i-1]+1)

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

for i in range(N):
    A0=A.copy()
    A0.pop(i)
    A0=sorted(A0)
    
    ii=0
    C=0
    L=0
    while ii<N-1:
        C=A0.count(A0[ii])
        ii+=C
        L=int(C*(C-1)/2)+L
    print(L)

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

L=0
C=[0]*N

for i in range(N):
    C[A[i]-1]+=1

for i in range(N):
    L+=int(C[i]*(C[i]-1)/2)
    
for i in A:
    print(L-C[i-1]+1)