Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a_uni = list(set(a))

a_ol = {}
def_count = 0
for i in a_uni:
    a_co = a.count(i)
    a_ol[i] = a_co
    def_count += a_co * (a_co - 1)

def_count //= 2

for k in a:
    print(def_count - a_ol[k] + 1)



Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))


a_ol = Counter(a)
def_count = 0
for item in a_ol.items():
    a_co = item[1]
    def_count += a_co * (a_co - 1)

def_count //= 2

for k in a:
    print(def_count - a_ol[k] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a_uni = list(set(a))

a_ol = {}
def_count = 0
for i in a_uni:
    a_co = a.count(i)
    a_ol[i] = a_co
    def_count += a_co * (a_co - 1)

def_count //= 2

for k in range(n):
    print(def_count - a_ol[a[k]] + 1)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))


a_ol = Counter(a)
def_count = 0
for item in a_ol.items():
    a_co = item[1]
    def_count += a_co * (a_co - 1)

def_count //= 2

for k in a:
    print(def_count - a_ol[k] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a_uni = list(set(a))

a_ol = {}
def_count = 0
for i in a_uni:
    a_co = a.count(i)
    a_ol[i] = a_co
    def_count += a_co * (a_co - 1) // 2

for k in range(n):
    print(def_count - a_ol[a[k]] + 1)


Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))


a_ol = Counter(a)
def_count = 0
for item in a_ol.items():
    a_co = item[1]
    def_count += a_co * (a_co - 1)

def_count //= 2

for k in a:
    print(def_count - a_ol[k] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a_uni = list(set(a))

a_ol = {}
def_count = 0
for i in a_uni:
    a_co = a.count(i)
    if a_co > 1:
        a_ol[i] = a_co
        def_count += a_co * (a_co - 1) // 2

for k in range(n):
    if a[k] in a_ol:
        print(def_count - a_ol[a[k]] + 1)
    else:
        print(def_count)



Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))


a_ol = Counter(a)
def_count = 0
for item in a_ol.items():
    a_co = item[1]
    def_count += a_co * (a_co - 1)

def_count //= 2

for k in a:
    print(def_count - a_ol[k] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a_uni = list(set(a))

a_ol = {}

for i in a_uni:
    a_co = a.count(i)
    if a_co > 1:
        a_ol[i] = a_co


def_count = sum([i * (i - 1) // 2 for i in a_ol.values()])
for k in range(n):
    if a[k] in a_ol:
        print(def_count - (a_ol[a[k]] - 1))
    else:
        print(def_count)



Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))


a_ol = Counter(a)
def_count = 0
for item in a_ol.items():
    a_co = item[1]
    def_count += a_co * (a_co - 1)

def_count //= 2

for k in a:
    print(def_count - a_ol[k] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a_uni = list(set(a))

a_ol = []
a_counts = []
for i in a_uni:
    a_co = a.count(i)
    if a_co > 1:
        a_ol.append(i)
        a_counts.append(a_co)


def_count = sum([i * (i - 1) // 2 for i in a_counts])
for k in range(n):
    count = 0
    if a[k] in a_ol:
        count = def_count - (a_counts[a_ol.index(a[k])] - 1)
    else:
        count = def_count
    print(count)



Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))


a_ol = Counter(a)
def_count = 0
for item in a_ol.items():
    a_co = item[1]
    def_count += a_co * (a_co - 1)

def_count //= 2

for k in a:
    print(def_count - a_ol[k] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a_uni = list(set(a))

a_ol = []
a_counts = []
for i in a_uni:
    a_co = a.count(i)
    if a_co > 1:
        a_ol.append(i)
        a_counts.append(a_co)

def_count = sum([i * (i - 1) // 2 for i in a_counts])
for k in range(n):
    count = 0
    if a[k] in a_ol:
        a_counts[a_ol.index(a[k])] -= 1
        count = sum([i * (i - 1) // 2 for i in a_counts])
        a_counts[a_ol.index(a[k])] += 1
    else:
        count = def_count
    print(count)



Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))


a_ol = Counter(a)
def_count = 0
for item in a_ol.items():
    a_co = item[1]
    def_count += a_co * (a_co - 1)

def_count //= 2

for k in a:
    print(def_count - a_ol[k] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a_uni = list(set(a))

for k in range(n):
    b = a.copy()
    del b[k]
    count = 0
    for i in a_uni:
        ol = b.count(i)
        count += ol * (ol - 1) // 2
    print(count)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))


a_ol = Counter(a)
def_count = 0
for item in a_ol.items():
    a_co = item[1]
    def_count += a_co * (a_co - 1)

def_count //= 2

for k in a:
    print(def_count - a_ol[k] + 1)