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

a_2 = [0 for i in range(n)]
for i in range(n):
    a_2[a[i]-1] += 1

al = [0 for i in range(n)]
c = 0
for i in a_2:
    if i > 1:
        al[c] += i * (i-1) / 2
    c += 1

for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sum(al)-(al[f-1]-t*(t-1)/2)))
    


Fixed submission:
n = int(input())
a = list(map(int,input().split()))

a_2 = [0 for i in range(n)]
for i in range(n):
    a_2[a[i]-1] += 1

al = [0 for i in range(n)]
c = 0
for i in a_2:
    if i > 1:
        al[c] += i * (i-1) / 2
    c += 1

sine = sum(al)
for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sine-(al[f-1]-t*(t-1)/2)))

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

a_2 = [0 for i in range(n)]
for i in range(n):
    a_2[a[i]-1] += 1

al = [0 for i in range(n)]
c = 0
for i in a_2:
    al[c] += int(i * (i-1) / 2)
    c += 1

for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sum(al)-(al[f-1]-t*(t-1)/2)))
    


Fixed submission:
n = int(input())
a = list(map(int,input().split()))

a_2 = [0 for i in range(n)]
for i in range(n):
    a_2[a[i]-1] += 1

al = [0 for i in range(n)]
c = 0
for i in a_2:
    if i > 1:
        al[c] += i * (i-1) / 2
    c += 1

sine = sum(al)
for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sine-(al[f-1]-t*(t-1)/2)))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

a_2 = [0 for i in range(n)]
for i in range(n):
    a_2[a[i]-1] += 1

al = []
for i in a_2:
    pass
#    al.append(int(i * (i-1) / 2))

for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sum(al)-(al[f-1]-t*(t-1)/2)))
    


Fixed submission:
n = int(input())
a = list(map(int,input().split()))

a_2 = [0 for i in range(n)]
for i in range(n):
    a_2[a[i]-1] += 1

al = [0 for i in range(n)]
c = 0
for i in a_2:
    if i > 1:
        al[c] += i * (i-1) / 2
    c += 1

sine = sum(al)
for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sine-(al[f-1]-t*(t-1)/2)))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

a_2 = [0 for i in range(n)]
for i in range(n):
    a_2[a[i]-1] += 1

al = []
#for i in a_2:
#    al.append(int(i * (i-1) / 2))

for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sum(al)-(al[f-1]-t*(t-1)/2)))
    


Fixed submission:
n = int(input())
a = list(map(int,input().split()))

a_2 = [0 for i in range(n)]
for i in range(n):
    a_2[a[i]-1] += 1

al = [0 for i in range(n)]
c = 0
for i in a_2:
    if i > 1:
        al[c] += i * (i-1) / 2
    c += 1

sine = sum(al)
for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sine-(al[f-1]-t*(t-1)/2)))

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

a_2 = [0 for i in range(n)]
for i in range(n):
    a_2[a[i]-1] += 1

al = []
for i in a_2:
    al.append(int(i * (i-1) / 2))

for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sum(al)-(al[f-1]-t*(t-1)/2)))
    


Fixed submission:
n = int(input())
a = list(map(int,input().split()))

a_2 = [0 for i in range(n)]
for i in range(n):
    a_2[a[i]-1] += 1

al = [0 for i in range(n)]
c = 0
for i in a_2:
    if i > 1:
        al[c] += i * (i-1) / 2
    c += 1

sine = sum(al)
for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sine-(al[f-1]-t*(t-1)/2)))

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

a_2 = [0 for i in range(max(a))]
al = []
for i in range(a_m):
    a_2[i] += a.count(i+1)
    al.append(int(a_2[i] * (a_2[i]-1) / 2))

al_s = sum(al)

for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(al_s-(al[f-1]-t*(t-1)/2)))
    


Fixed submission:
n = int(input())
a = list(map(int,input().split()))

a_2 = [0 for i in range(n)]
for i in range(n):
    a_2[a[i]-1] += 1

al = [0 for i in range(n)]
c = 0
for i in a_2:
    if i > 1:
        al[c] += i * (i-1) / 2
    c += 1

sine = sum(al)
for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sine-(al[f-1]-t*(t-1)/2)))

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

a_2 = [0 for i in range(max(a))]
for i in range(max(a)):
    a_2[i] += a.count(i+1)

al = []
for i in a_2:
    al.append(int(i * (i-1) / 2))

for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sum(al)-(al[f-1]-t*(t-1)/2)))
    


Fixed submission:
n = int(input())
a = list(map(int,input().split()))

a_2 = [0 for i in range(n)]
for i in range(n):
    a_2[a[i]-1] += 1

al = [0 for i in range(n)]
c = 0
for i in a_2:
    if i > 1:
        al[c] += i * (i-1) / 2
    c += 1

sine = sum(al)
for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sine-(al[f-1]-t*(t-1)/2)))