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

datas = [0] * (n+1)
for a in an:
    datas[a] += 1

for k in range(0,n):
    ans=0
    for i in range(1,n+1):
        if datas[i] > 1:
            if i == an[k]:
                ans += (datas[i]-1) * (datas[i]-2)/2
            else:
                ans += datas[i] * (datas[i]-1)/2
    print(int(ans))



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

datas = [0] * (n+1)
for a in an:
    datas[a] += 1

ans = 0
for i in range(1,n+1):
    if datas[i] > 1:
        ans += datas[i] * (datas[i]-1)/2
ans = int(ans)

for k in range(0,n):
    if datas[an[k]] > 1:
        print(int(ans - datas[an[k]] * (datas[an[k]]-1)/2 + (datas[an[k]]-1) * (datas[an[k]]-2)/2))
    else:
        print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
an= list(map(int, input().split()))

datas = [0] * n
for a in an:
    datas[a] += 1

for k in range(0,n):
    ans=0
    for i in range(1,n):
        if datas[i] > 1:
            if i == an[k]:
                ans += (datas[i]-1) * (datas[i]-2)/2
            else:
                ans += datas[i] * (datas[i]-1)/2
    print(int(ans))



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

datas = [0] * (n+1)
for a in an:
    datas[a] += 1

ans = 0
for i in range(1,n+1):
    if datas[i] > 1:
        ans += datas[i] * (datas[i]-1)/2
ans = int(ans)

for k in range(0,n):
    if datas[an[k]] > 1:
        print(int(ans - datas[an[k]] * (datas[an[k]]-1)/2 + (datas[an[k]]-1) * (datas[an[k]]-2)/2))
    else:
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import collections

if True:
    n = int(input())
    an= list(map(int, input().split()))

else:
   # n=5
   # an=[1,1,2,1,2]
    n=8
    an=[1,2,1,4,2,1,4,1]

ans = 0
c = collections.Counter(an)
datas = c.most_common()
ans = 0

for k in range(0,n):
    # an2.sort()
    # print(an2)
    ans=0
    for data in datas:
        if data[0] == an[k]:
            if data[1] > 1:
                ans += (data[1]-1) * (data[1]-2)/2
        else:
            ans += data[1] * (data[1]-1)/2
    print(int(ans))



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

datas = [0] * (n+1)
for a in an:
    datas[a] += 1

ans = 0
for i in range(1,n+1):
    if datas[i] > 1:
        ans += datas[i] * (datas[i]-1)/2
ans = int(ans)

for k in range(0,n):
    if datas[an[k]] > 1:
        print(int(ans - datas[an[k]] * (datas[an[k]]-1)/2 + (datas[an[k]]-1) * (datas[an[k]]-2)/2))
    else:
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import collections

n = int(input())
an= list(map(int, input().split()))

for k in range(0,n):
    before = ""
    ans = 0
    same_count = 0
    c = collections.Counter(an)
    datas = c.most_common()
    ans = 0
    for data in datas:
        if data[0] == an[k]:
            if data[1] > 1:
                ans += (data[1]-1) * (data[1]-2)/2
        else:
            ans += data[1] * (data[1]-1)/2
    print(int(ans))

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

datas = [0] * (n+1)
for a in an:
    datas[a] += 1

ans = 0
for i in range(1,n+1):
    if datas[i] > 1:
        ans += datas[i] * (datas[i]-1)/2
ans = int(ans)

for k in range(0,n):
    if datas[an[k]] > 1:
        print(int(ans - datas[an[k]] * (datas[an[k]]-1)/2 + (datas[an[k]]-1) * (datas[an[k]]-2)/2))
    else:
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import collections
n = int(input())
an= list(map(int, input().split()))

for k in range(0,n):
    an2 = an[:]
    del an2[k]
    c = collections.Counter(an2)
    datas = c.most_common()
    ans = 0
    for data in datas:
        ans += data[1] * (data[1]-1)/2
    print(int(ans))
    an2.clear()


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

datas = [0] * (n+1)
for a in an:
    datas[a] += 1

ans = 0
for i in range(1,n+1):
    if datas[i] > 1:
        ans += datas[i] * (datas[i]-1)/2
ans = int(ans)

for k in range(0,n):
    if datas[an[k]] > 1:
        print(int(ans - datas[an[k]] * (datas[an[k]]-1)/2 + (datas[an[k]]-1) * (datas[an[k]]-2)/2))
    else:
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
if True:
    n = int(input())
    an= list(map(int, input().split()))

else:
   # n=5
   # an=[1,1,2,1,2]
    n=8
    an=[1,2,1,4,2,1,4,1]


for k in range(0,n):
    an2 = an[:]
    del an2[k]
    an2.sort()
    # print(an2)
    before = ""
    ans = 0
    same_count = 0
    for a in an2:
        if a == before:
            same_count += 1
        elif same_count > 0:
            # print(same_count)
            ans += same_count * (same_count+1)/2
            same_count = 0
        before = a
    if same_count > 0:
        ans += same_count * int((same_count+1)/2)
    print(int(ans))
    an2.clear()



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

datas = [0] * (n+1)
for a in an:
    datas[a] += 1

ans = 0
for i in range(1,n+1):
    if datas[i] > 1:
        ans += datas[i] * (datas[i]-1)/2
ans = int(ans)

for k in range(0,n):
    if datas[an[k]] > 1:
        print(int(ans - datas[an[k]] * (datas[an[k]]-1)/2 + (datas[an[k]]-1) * (datas[an[k]]-2)/2))
    else:
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
if True:
    n = int(input())
    an= list(map(int, input().split()))

else:
   n=5
   an=[1,1,2,1,2]


for k in range(0,n):
    an2 = an[:]
    del an2[k]
    # print(an2)
    ans = 0
    for b1 in range(0,n-1):
        for b2 in range(b1+1,n-1):
            if an2[b1] == an2[b2]:
                ans += 1
    print(int(ans))
    an2.clear()

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

datas = [0] * (n+1)
for a in an:
    datas[a] += 1

ans = 0
for i in range(1,n+1):
    if datas[i] > 1:
        ans += datas[i] * (datas[i]-1)/2
ans = int(ans)

for k in range(0,n):
    if datas[an[k]] > 1:
        print(int(ans - datas[an[k]] * (datas[an[k]]-1)/2 + (datas[an[k]]-1) * (datas[an[k]]-2)/2))
    else:
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
if True:
    n = int(input())
    an= list(map(int, input().split()))

else:
   n=5
   an=[1,1,2,1,2]


for k in range(0,n):
    an2 = an[:]
    del an2[k]
    # print(an2)
    ans = 0
    for b1 in range(0,n-1):
        for b2 in range(0,n-1):
            if b1 == b2:
                continue
            if an2[b1] == an2[b2]:
                ans += 1
    print(int(ans/2))

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

datas = [0] * (n+1)
for a in an:
    datas[a] += 1

ans = 0
for i in range(1,n+1):
    if datas[i] > 1:
        ans += datas[i] * (datas[i]-1)/2
ans = int(ans)

for k in range(0,n):
    if datas[an[k]] > 1:
        print(int(ans - datas[an[k]] * (datas[an[k]]-1)/2 + (datas[an[k]]-1) * (datas[an[k]]-2)/2))
    else:
        print(ans)