Buggy python submission (verdict: Time Limit Exceeded):
# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 各数字の個数を求める
Cn = [An.count(i) for i in range(1,N+1)]
 
# 全部の組み合わせ
s = 0
for i in range(1,N+1):
    s += Cn[i-1]*(Cn[i-1]-1) // 2

for i in range(1,N+1):
    print(s - (Cn[An[i-1]-1] - 1))

Fixed submission:
import collections as c

# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 各数字の個数を求める
Cn = c.Counter(An)
 
# 全部の組み合わせ
s = 0
for v in Cn.values():
    s += int(v*(v-1) / 2)

for i in range(0,N):
    print(s - (Cn[An[i]] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 組み合わせ
L = [0]
for i in range(0,N+1):
    L.append(i*(i+1)//2)

# 各数字の個数を求める
Cn = [An.count(i) for i in range(1,N+1)]
 
# 全部の組み合わせ
Dn = [L[Cn[i-1]] for i in range(1,N+1)]
s = sum(Dn)
 
for i in range(1,N+1):
    print(s - (Cn[An[i-1]-1] - 1))

Fixed submission:
import collections as c

# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 各数字の個数を求める
Cn = c.Counter(An)
 
# 全部の組み合わせ
s = 0
for v in Cn.values():
    s += int(v*(v-1) / 2)

for i in range(0,N):
    print(s - (Cn[An[i]] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 組み合わせ
L = [0]
for i in range(0,N+1):
    L.append(int(i*(i+1)/2))

# 各数字の個数を求める
Cn = [An.count(i) for i in range(1,N+1)]
 
# 全部の組み合わせ
Dn = [L[Cn[i-1]] for i in range(1,N+1)]
s = sum(Dn)

for i in range(1,N+1):
    print(s - (Cn[An[i-1]-1] - 1))

Fixed submission:
import collections as c

# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 各数字の個数を求める
Cn = c.Counter(An)
 
# 全部の組み合わせ
s = 0
for v in Cn.values():
    s += int(v*(v-1) / 2)

for i in range(0,N):
    print(s - (Cn[An[i]] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
An = [int(x) for x in input().split()]  

# ボールを全部使えるときの合計を求める
s = 0
for i in range(1,N+1):
    b = An.count(i)
    if b > 1:
        s += int(b*(b-1) / 2)

for k in range(N):
    print(s - (An.count(An[k])-1))

Fixed submission:
import collections as c

# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 各数字の個数を求める
Cn = c.Counter(An)
 
# 全部の組み合わせ
s = 0
for v in Cn.values():
    s += int(v*(v-1) / 2)

for i in range(0,N):
    print(s - (Cn[An[i]] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
# import math

N = int(input())
An = [int(x) for x in input().split()]  
Cn = [An.count(i) for i in range(1,N+1)]  # どの数字が何個あるか？

# ボールを全部使えるときの合計を求める
s = 0
for i in range(N):
    if Cn[i] > 1:
        s += int(Cn[i]*(Cn[i]-1) / 2)

for k in range(N):
    print(s - (Cn[An[k]-1]-1))

Fixed submission:
import collections as c

# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 各数字の個数を求める
Cn = c.Counter(An)
 
# 全部の組み合わせ
s = 0
for v in Cn.values():
    s += int(v*(v-1) / 2)

for i in range(0,N):
    print(s - (Cn[An[i]] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
# import math
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())
An = [int(x) for x in input().split()]  
Cn = [An.count(i) for i in range(1,N+1)]  # どの数字が何個あるか？

# ボールを全部使えるときの合計を求める
s = 0
for i in range(N):
    if Cn[i] > 1:
        # s += int(math.factorial(Cn[i]) / (math.factorial(Cn[i]-2) * 2))
        s += int(cmb(Cn[i],2))

for k in range(N):
    print(s - (Cn[An[k]-1]-1))

Fixed submission:
import collections as c

# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 各数字の個数を求める
Cn = c.Counter(An)
 
# 全部の組み合わせ
s = 0
for v in Cn.values():
    s += int(v*(v-1) / 2)

for i in range(0,N):
    print(s - (Cn[An[i]] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
import math

N = int(input())
An = [int(x) for x in input().split()]  
Cn = [An.count(i) for i in range(1,N+1)]  # どの数字が何個あるか？

# ボールを全部使えるときの合計を求める
s = 0
for i in range(N):
    if Cn[i] > 1:
        s += int(math.factorial(Cn[i]) / (math.factorial(Cn[i]-2) * 2))
        # s += int(fact(Cn[i]) / (fact(Cn[i]-2) * 2))

for k in range(N):
    print(s - (Cn[An[k]-1]-1))

Fixed submission:
import collections as c

# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 各数字の個数を求める
Cn = c.Counter(An)
 
# 全部の組み合わせ
s = 0
for v in Cn.values():
    s += int(v*(v-1) / 2)

for i in range(0,N):
    print(s - (Cn[An[i]] - 1))

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

N = int(input())
An = [int(x) for x in input().split()]  
Cn = [An.count(i) for i in range(1,N+1)]  # どの数字が何個あるか？

# ボールを全部使えるときの合計を求める
s = 0
for i in range(N):
    if Cn[i] > 1:
        s += int(comb(Cn[i],2))

for k in range(N):
    print(s - (Cn[An[k]-1]-1))

Fixed submission:
import collections as c

# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 各数字の個数を求める
Cn = c.Counter(An)
 
# 全部の組み合わせ
s = 0
for v in Cn.values():
    s += int(v*(v-1) / 2)

for i in range(0,N):
    print(s - (Cn[An[i]] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
import math

N = int(input())
An = [int(x) for x in input().split()]  
Cn = [An.count(i) for i in range(1,N+1)]  # どの数字が何個あるか？

# ボールを全部使えるときの合計を求める
s = 0
for i in range(N):
    if Cn[i] > 1:
        s += int(math.factorial(Cn[i]) / (math.factorial(Cn[i]-2) * 2))

for k in range(N):
    print(s - (Cn[An[k]-1]-1))

Fixed submission:
import collections as c

# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 各数字の個数を求める
Cn = c.Counter(An)
 
# 全部の組み合わせ
s = 0
for v in Cn.values():
    s += int(v*(v-1) / 2)

for i in range(0,N):
    print(s - (Cn[An[i]] - 1))

Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
An = [int(x) for x in input().split()]
 
L = [0,0]
for i in range(N):
    if i > 1:
        L.append(int(math.factorial(i) / (math.factorial(i-2) * 2)))

Cn = [An.count(i) for i in range(1,N+1)]
s = sum([L[Cn[i]] for i in range(N)])

for k in range(N):
    print(sum(Dn) - (Cn[An[k]-1]-1))

Fixed submission:
import collections as c

# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 各数字の個数を求める
Cn = c.Counter(An)
 
# 全部の組み合わせ
s = 0
for v in Cn.values():
    s += int(v*(v-1) / 2)

for i in range(0,N):
    print(s - (Cn[An[i]] - 1))

Buggy python submission (verdict: Runtime Error):
N = int(input())
An = [int(x) for x in input().split()]
 
L = [0,0]
for i in range(N):
    if i > 1:
        L.append(int(math.factorial(i) / (math.factorial(i-2) * 2)))

Cn = [An.count(i) for i in range(1,N+1)]
s = sum([L[Cn[i]] for i in range(N)])

for k in range(N):
    print(sum(Dn) - (Cn[An[k]-1]-1))

Fixed submission:
import collections as c

# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 各数字の個数を求める
Cn = c.Counter(An)
 
# 全部の組み合わせ
s = 0
for v in Cn.values():
    s += int(v*(v-1) / 2)

for i in range(0,N):
    print(s - (Cn[An[i]] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
import math

N = int(input())
An = [int(x) for x in input().split()]
 
L = [0,0]
for i in range(N):
    if i > 1:
        L.append(int(math.factorial(i) / (math.factorial(i-2) * 2)))

for k in range(N):
    Bn = [An[i] for i in range(N) if not i == k]
    Cn = [Bn.count(i) for i in range(N)]
    Dn = [Cn.count(i)*L[i] for i in range(N)] 
    
    print(sum(Dn))

Fixed submission:
import collections as c

# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 各数字の個数を求める
Cn = c.Counter(An)
 
# 全部の組み合わせ
s = 0
for v in Cn.values():
    s += int(v*(v-1) / 2)

for i in range(0,N):
    print(s - (Cn[An[i]] - 1))

Buggy python submission (verdict: Runtime Error):
N = int(input())
An = [int(x) for x in input().split()]

L = [0,0]
for i in range(N):
    if i > 1:
        L.append(int(math.factorial(i) / (math.factorial(i-2) * 2)))

for k in range(N):
    Bn = [An[i] for i in range(N) if not i == k]
    Cn = [Bn.count(i) for i in range(N)]
    Dn = [Cn.count(i)*L[i] for i in range(N)] 
    
    print(sum(Dn))

Fixed submission:
import collections as c

# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 各数字の個数を求める
Cn = c.Counter(An)
 
# 全部の組み合わせ
s = 0
for v in Cn.values():
    s += int(v*(v-1) / 2)

for i in range(0,N):
    print(s - (Cn[An[i]] - 1))

Buggy python submission (verdict: Runtime Error):
import copy

N = int(input())
An = [int(x) for x in input().split()]

for i in range(N):
    tmp = copy.copy(An)
    tmp.pop(i)
    
    c = 0
    for i in range(N):
        k = tmp.count(i)
        if k>1:
            c += int(math.factorial(k) / (math.factorial(k-2) * 2))
    print(c)

Fixed submission:
import collections as c

# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 各数字の個数を求める
Cn = c.Counter(An)
 
# 全部の組み合わせ
s = 0
for v in Cn.values():
    s += int(v*(v-1) / 2)

for i in range(0,N):
    print(s - (Cn[An[i]] - 1))