Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
N=int(input())
a=sys.stdin.readline().split()
A=[int(b) for b in a]
numbers=[0]*N
for a in range(1,N+1):
    kosuu=A.count(a)
    if kosuu<=1:
        pass
    else:
        numbers.insert(a-1,kosuu)
answers=[0]*N
for a in range(1,N+1):
    if numbers[a-1]>=2:
        b=numbers[a-1]*(numbers[a-1]-1)//2
        answers[a-1]+=b
kotae=sum(answers)
for a in range(N):
    z=A[a]
    if kotae==0:
        print(0)
    else:
        answer=kotae-numbers[z-1]+1
        print(answer)


Fixed submission:
import math
import sys
from collections import Counter
N=int(input())
a=sys.stdin.readline().split()
A=[int(b) for b in a]
numbers=[0]*N
count=Counter(A)
kotae=0
for a in range(N+1):
    b=count[a]
    kotae+=b*(b-1)//2
for a in A:
    print(kotae+1-count[a])

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
N=int(input())
a=sys.stdin.readline().split()
A=[int(b) for b in a]
numbers=[0]*N
for a in range(1,N+1):
    kosuu=A.count(a)
    if kosuu<=1:
        pass
    else:
        numbers.insert(a-1,kosuu)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
answers=[0]*N
for a in range(1,N+1):
    if numbers[a-1]>=2:
        b=combinations_count(numbers[a-1],2)
        answers[a-1]+=b
kotae=sum(answers)
for a in range(N):
    z=A[a]
    if kotae==0:
        print(0)
    else:
        answer=kotae-numbers[z-1]+1
        print(answer)


Fixed submission:
import math
import sys
from collections import Counter
N=int(input())
a=sys.stdin.readline().split()
A=[int(b) for b in a]
numbers=[0]*N
count=Counter(A)
kotae=0
for a in range(N+1):
    b=count[a]
    kotae+=b*(b-1)//2
for a in A:
    print(kotae+1-count[a])

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
N=int(input())
a=sys.stdin.readline().split()
A=[int(b) for b in a]
numbers=[0]*(2*10**5)
for a in range(1,N+1):
    kosuu=A.count(a)
    if kosuu<=1:
        pass
    else:
        numbers.insert(a-1,kosuu)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
answers=[0]*(N)
for a in range(1,N+1):
    if numbers[a-1]>=2:
        b=combinations_count(numbers[a-1],2)
        answers[a-1]+=b
kotae=sum(answers)
for a in range(N):
    z=A[a]
    if kotae==0:
        print(0)
    else:
        answer=kotae-numbers[z-1]+1
        print(answer)


Fixed submission:
import math
import sys
from collections import Counter
N=int(input())
a=sys.stdin.readline().split()
A=[int(b) for b in a]
numbers=[0]*N
count=Counter(A)
kotae=0
for a in range(N+1):
    b=count[a]
    kotae+=b*(b-1)//2
for a in A:
    print(kotae+1-count[a])

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
N=int(input())
a=sys.stdin.readline().split()
A=[int(b) for b in a]
numbers=[0]*(2*10**5)
for a in range(1,N+1):
    kosuu=A.count(a)
    if kosuu<=1:
        pass
    else:
        numbers.insert(a-1,kosuu)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
answers=[0]*(2*10**5)
for a in range(1,N+1):
    if numbers[a-1]>=2:
        b=combinations_count(numbers[a-1],2)
        answers[a-1]+=b
kotae=sum(answers)
for a in range(N):
    z=A[a]
    if kotae==0:
        print(0)
    else:
        answer=kotae-numbers[z-1]+1
        print(answer)


Fixed submission:
import math
import sys
from collections import Counter
N=int(input())
a=sys.stdin.readline().split()
A=[int(b) for b in a]
numbers=[0]*N
count=Counter(A)
kotae=0
for a in range(N+1):
    b=count[a]
    kotae+=b*(b-1)//2
for a in A:
    print(kotae+1-count[a])

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
N=int(input())
a=sys.stdin.readline().split()
A=[int(b) for b in a]
numbers=[0]*(2*10**5)
for a in range(1,N+1):
    kosuu=A.count(a)
    if kosuu<=1:
        pass
    else:
        numbers.insert(a-1,kosuu)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
answers=[0]*(2*10**5)
for a in range(1,N+1):
    if numbers[a-1]>=2:
        b=combinations_count(numbers[a-1],2)
        answers[a-1]+=b
kotae=sum(answers)
for a in range(N):
    z=A[a]
    if answers[z-1]==0:
        print(0)
    else:
        answer=kotae-numbers[z-1]+1
        print(answer)
        

Fixed submission:
import math
import sys
from collections import Counter
N=int(input())
a=sys.stdin.readline().split()
A=[int(b) for b in a]
numbers=[0]*N
count=Counter(A)
kotae=0
for a in range(N+1):
    b=count[a]
    kotae+=b*(b-1)//2
for a in A:
    print(kotae+1-count[a])

Buggy python submission (verdict: Time Limit Exceeded):
import math
N=int(input())
a=input().split()
A=[int(b) for b in a]
numbers=[0]*(2*10**5)
for a in range(1,N+1):
    kosuu=A.count(a)
    if kosuu<=1:
        pass
    else:
        numbers.insert(a-1,kosuu)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
answers=[0]*(2*10**5)
for a in range(1,N+1):
    if numbers[a-1]>=2:
        b=combinations_count(numbers[a-1],2)
        answers[a-1]+=b
kotae=sum(answers)
for a in range(N):
    z=A[a]
    if answers[z-1]==0:
        print(0)
    else:
        answer=kotae-numbers[z-1]+1
        print(answer)


Fixed submission:
import math
import sys
from collections import Counter
N=int(input())
a=sys.stdin.readline().split()
A=[int(b) for b in a]
numbers=[0]*N
count=Counter(A)
kotae=0
for a in range(N+1):
    b=count[a]
    kotae+=b*(b-1)//2
for a in A:
    print(kotae+1-count[a])

Buggy python submission (verdict: Time Limit Exceeded):
import math
N=int(input())
a=input().split()
A=[int(b) for b in a]
numbers=[0]*(2*10**5)
for a in range(1,N+1):
    kosuu=A.count(a)
    if kosuu<=1:
        pass
    else:
        numbers.insert(a-1,kosuu)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
answers=[0]*(2*10**5)
for a in range(1,N+1):
    if numbers[a-1]>=2:
        b=combinations_count(numbers[a-1],2)
        answers[a-1]+=b
kotae=sum(answers)
for a in range(N):
    z=A[a]
    if answers[z-1]==0:
        print(0)
    else:
        answer=kotae-numbers[z-1]+1
        print(answer)


Fixed submission:
import math
import sys
from collections import Counter
N=int(input())
a=sys.stdin.readline().split()
A=[int(b) for b in a]
numbers=[0]*N
count=Counter(A)
kotae=0
for a in range(N+1):
    b=count[a]
    kotae+=b*(b-1)//2
for a in A:
    print(kotae+1-count[a])

Buggy python submission (verdict: Time Limit Exceeded):
import math
N=int(input())
a=input().split()
A=[int(b) for b in a]
numbers=[0]*(2*10**5)
for a in range(1,2*10**5+1):
    kosuu=A.count(a)
    if kosuu<=1:
        pass
    else:
        numbers.insert(a-1,kosuu)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
answers=[0]*(2*10**5)
for a in range(1,2*10**5+1):
    if numbers[a-1]>=2:
        b=combinations_count(numbers[a-1],2)
        answers[a-1]+=b
kotae=sum(answers)
for a in range(N):
    z=A[a]
    if answers[z-1]==0:
        print(0)
    else:
        answer=kotae-numbers[z-1]+1
        print(answer)
        

Fixed submission:
import math
import sys
from collections import Counter
N=int(input())
a=sys.stdin.readline().split()
A=[int(b) for b in a]
numbers=[0]*N
count=Counter(A)
kotae=0
for a in range(N+1):
    b=count[a]
    kotae+=b*(b-1)//2
for a in A:
    print(kotae+1-count[a])