Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())
A = list(map(int, input().split()))
dic = {}
for a in A:
    if a in dic: dic[a] += 1
    else: dic[a] = 1

C = {0:0}

sum_ni = 0
for i in range(1, 2*10**5+1):
    C[i] = i*(i-1)//2

ans2 = {}
for k, v in dic.items():
    sum_ni += C[v]



ans = []
for i in range(N):
    dic2 = dic.copy()
    dic2[A[i]] -= 1
    a = sum_ni - C[dic[A[i]]] + C[dic[A[i]]-1]

    ans.append(a)


for a in ans:
    print(a)


Fixed submission:
#!/usr/bin/env python3

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())
A = list(map(int, input().split()))
dic = {}
for a in A:
    if a in dic: dic[a] += 1
    else: dic[a] = 1

C = {0:0}

sum_ni = 0
for i in range(1, N+1):
    C[i] = i*(i-1)//2

D = {}
for k, v in dic.items():
    sum_ni += C[v]


for k, v in dic.items():
    D[k] = sum_ni - C[dic[k]] + C[dic[k]-1]

for i in range(N):
    print(D[A[i]])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())
A = list(map(int, input().split()))
dic = {}
for a in A:
    if a in dic: dic[a] += 1
    else: dic[a] = 1

C = {0:0}

for i in range(1, 2*10**5+1):
    C[i] = i*(i-1)//2

ans = []
for i in range(N):
    dic2 = dic.copy()
    dic2[A[i]] -= 1
    a = 0

    for k, v in dic2.items():
        a += C[v]

    ans.append(a)


for a in ans:
    print(a)


Fixed submission:
#!/usr/bin/env python3

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())
A = list(map(int, input().split()))
dic = {}
for a in A:
    if a in dic: dic[a] += 1
    else: dic[a] = 1

C = {0:0}

sum_ni = 0
for i in range(1, N+1):
    C[i] = i*(i-1)//2

D = {}
for k, v in dic.items():
    sum_ni += C[v]


for k, v in dic.items():
    D[k] = sum_ni - C[dic[k]] + C[dic[k]-1]

for i in range(N):
    print(D[A[i]])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())
A = list(map(int, input().split()))
dic = {}
for a in A:
    if a in dic: dic[a] += 1
    else: dic[a] = 1

C = {0:0}

for i in range(1, 10*10**5+1):
    C[i] = i*(i-1)//2

ans = []
for i in range(N):
    dic2 = dic.copy()
    dic2[A[i]] -= 1
    a = 0

    for k, v in dic2.items():
        a += C[v]

    ans.append(a)


for a in ans:
    print(a)


Fixed submission:
#!/usr/bin/env python3

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())
A = list(map(int, input().split()))
dic = {}
for a in A:
    if a in dic: dic[a] += 1
    else: dic[a] = 1

C = {0:0}

sum_ni = 0
for i in range(1, N+1):
    C[i] = i*(i-1)//2

D = {}
for k, v in dic.items():
    sum_ni += C[v]


for k, v in dic.items():
    D[k] = sum_ni - C[dic[k]] + C[dic[k]-1]

for i in range(N):
    print(D[A[i]])