Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
dA = {}
A = []
for a in input().split():
    A.append(a)
    if a in dA:
        dA[a] += 1
    else:
        dA[a] = 1

cA = {}
for a in dA:
    cA[a] = dA[a] * (dA[a] - 1) // 2

for a in A:
    print(sum(cA.values()) - dA[a] + 1)


Fixed submission:
n = int(input())
dA = {}
A = []
for a in input().split():
    A.append(a)
    if a in dA:
        dA[a] += 1
    else:
        dA[a] = 1

cA = {}
for a in dA:
    cA[a] = dA[a] * (dA[a] - 1) // 2

s = sum(cA.values())
for a in A:
    print(s - dA[a] + 1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
dA = {}
for a in input().split():
    if a in dA:
        dA[a] += 1
    else:
        dA[a] = 1

cA = {}
for a in dA:
    cA[a] = dA[a] * (dA[a] - 1) // 2

for a in A:
    print(sum(cA.values()) - dA[a] + 1)


Fixed submission:
n = int(input())
dA = {}
A = []
for a in input().split():
    A.append(a)
    if a in dA:
        dA[a] += 1
    else:
        dA[a] = 1

cA = {}
for a in dA:
    cA[a] = dA[a] * (dA[a] - 1) // 2

s = sum(cA.values())
for a in A:
    print(s - dA[a] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = input().split()
if len(set(A)) == 1:
    for _ in range(n):
        print(((n - 1) * (n - 2)) // 2)
    exit()
elif len(set(A)) == len(A):
    for _ in range(n):
        print(0)
    exit()

dA = {}
for a in A:
    if a in dA:
        dA[a] += 1
    else:
        dA[a] = 1

for a in dA:
    dA[a] = dA[a] * (dA[a] - 1) // 2

for a in A:
    print(sum(dA.values()) - A.count(a) + 1)


Fixed submission:
n = int(input())
dA = {}
A = []
for a in input().split():
    A.append(a)
    if a in dA:
        dA[a] += 1
    else:
        dA[a] = 1

cA = {}
for a in dA:
    cA[a] = dA[a] * (dA[a] - 1) // 2

s = sum(cA.values())
for a in A:
    print(s - dA[a] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = input().split()
if len(set(A)) == 1:
    for _ in range(n):
        print(((n - 1) * (n - 2)) // 2)
    exit()
elif len(set(A)) == len(A):
    for _ in range(n):
        print(0)
    exit()

dA = {}
for a in A:
    if a in dA:
        dA[a] += 1
    else:
        dA[a] = 1

kA = {}
for a in dA:
    kA[a] = (dA[a] - 1) * (dA[a] - 2) // 2
    dA[a] = dA[a] * (dA[a] - 1) // 2

for a in A:
    print(sum(dA.values()) - A.count(a) + 1)


Fixed submission:
n = int(input())
dA = {}
A = []
for a in input().split():
    A.append(a)
    if a in dA:
        dA[a] += 1
    else:
        dA[a] = 1

cA = {}
for a in dA:
    cA[a] = dA[a] * (dA[a] - 1) // 2

s = sum(cA.values())
for a in A:
    print(s - dA[a] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = input().split()
if len(set(A)) == 1:
    for _ in range(n):
        print(((n - 1) * (n - 2)) // 2)
    exit()
elif len(set(A)) == len(A):
    for _ in range(n):
        print(0)
    exit()

dA = {}
for a in A:
    if a in dA:
        dA[a] += 1
    else:
        dA[a] = 1

kA = {}
for a in dA:
    kA[a] = (dA[a] - 1) * (dA[a] - 2) // 2
    dA[a] = dA[a] * (dA[a] - 1) // 2

for a in A:
    print(sum(dA.values()) - dA[a] + kA[a])


Fixed submission:
n = int(input())
dA = {}
A = []
for a in input().split():
    A.append(a)
    if a in dA:
        dA[a] += 1
    else:
        dA[a] = 1

cA = {}
for a in dA:
    cA[a] = dA[a] * (dA[a] - 1) // 2

s = sum(cA.values())
for a in A:
    print(s - dA[a] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = input().split()
if len(set(A)) == 1:
    for _ in range(n):
        print(((n - 1) * (n - 2)) // 2)
    exit()
elif len(set(A)) == len(A):
    for _ in range(n):
        print(0)
    exit()

dA = {}
for a in A:
    if a in dA:
        dA[a] += 1
    else:
        dA[a] = 1

kA = {}
for a in dA:
    kA[a] = (dA[a] - 1) * (dA[a] - 2) // 2
    dA[a] = dA[a] * (dA[a] - 1) // 2

for a in A:
    print(sum(dA.values()) - dA[a] + kA[a])


Fixed submission:
n = int(input())
dA = {}
A = []
for a in input().split():
    A.append(a)
    if a in dA:
        dA[a] += 1
    else:
        dA[a] = 1

cA = {}
for a in dA:
    cA[a] = dA[a] * (dA[a] - 1) // 2

s = sum(cA.values())
for a in A:
    print(s - dA[a] + 1)