Buggy python submission (verdict: Runtime Error):
import collections
n = int(input())
a = list(map(str,input().split()))
ls = [i for i in range(10**5)]
c = collections.Counter(a)
comon = c.most_common()
ans = 0

for i in comon:
    if i != 1:
      ls[int(i[0])] = i[1]
      ans += (i[1]*(i[1]-1)//2)

for i in a:
    co = ls[int(i)]
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

      

Fixed submission:
import collections
n = int(input())
a = list(map(str,input().split()))
ls = [i for i in range(2*10**5)]
c = collections.Counter(a)
comon = c.most_common()
ans = 0

for i in comon:
    if i != 1:
      ls[int(i[0])] = i[1]
      ans += (i[1]*(i[1]-1)//2)

for i in a:
    co = ls[int(i)]
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

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

c = collections.Counter(a)
keys, values = zip(*c.most_common())
ans = 0
for i in values:
  if i != 1:
  	ans += (i*(i-1)//2)

for i in a:
    ct = 0
    for j in keys:
      if i == j:
        co = values[ct]
        break
      ct += 1
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

      

Fixed submission:
import collections
n = int(input())
a = list(map(str,input().split()))
ls = [i for i in range(2*10**5)]
c = collections.Counter(a)
comon = c.most_common()
ans = 0

for i in comon:
    if i != 1:
      ls[int(i[0])] = i[1]
      ans += (i[1]*(i[1]-1)//2)

for i in a:
    co = ls[int(i)]
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

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

c = collections.Counter(a)

keys, values = zip(*c.most_common())

ans = 0
co = 0
for i in values:
  if i != 1:
  	ans += (i*(i-1)//2)

for i in a:
    for j in range(len(keys)-1,-1,-1):
      if i == keys[j]:
        co = values[j]
        break
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

      

Fixed submission:
import collections
n = int(input())
a = list(map(str,input().split()))
ls = [i for i in range(2*10**5)]
c = collections.Counter(a)
comon = c.most_common()
ans = 0

for i in comon:
    if i != 1:
      ls[int(i[0])] = i[1]
      ans += (i[1]*(i[1]-1)//2)

for i in a:
    co = ls[int(i)]
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

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

c = collections.Counter(a)

keys, values = zip(*c.most_common())

ans = 0

for i in values:
  if i != 1:
  	ans += (i*(i-1)//2)

for i in a:
    for j in range(len(keys)):
      if i == keys[j]:
        co = values[j]
        break
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

      

Fixed submission:
import collections
n = int(input())
a = list(map(str,input().split()))
ls = [i for i in range(2*10**5)]
c = collections.Counter(a)
comon = c.most_common()
ans = 0

for i in comon:
    if i != 1:
      ls[int(i[0])] = i[1]
      ans += (i[1]*(i[1]-1)//2)

for i in a:
    co = ls[int(i)]
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

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

c = collections.Counter(a)

keys, values = zip(*c.most_common())

ans = 0

for i in values:
  if i != 1:
  	ans += (i*(i-1)//2)

for i in a:
    for j in range(len(keys)):
      if i == keys[j]:
        co = values[j]
        break
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

      

Fixed submission:
import collections
n = int(input())
a = list(map(str,input().split()))
ls = [i for i in range(2*10**5)]
c = collections.Counter(a)
comon = c.most_common()
ans = 0

for i in comon:
    if i != 1:
      ls[int(i[0])] = i[1]
      ans += (i[1]*(i[1]-1)//2)

for i in a:
    co = ls[int(i)]
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

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

c = collections.Counter(a)

keys, values = zip(*c.most_common())

ans = 0

for i in values:
  if i != 1:
  	ans += (i*(i-1)//2)

for i in a:
    for j in range(len(keys)):
      if i == keys[j]:
        co = values[j]
        break
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

      

Fixed submission:
import collections
n = int(input())
a = list(map(str,input().split()))
ls = [i for i in range(2*10**5)]
c = collections.Counter(a)
comon = c.most_common()
ans = 0

for i in comon:
    if i != 1:
      ls[int(i[0])] = i[1]
      ans += (i[1]*(i[1]-1)//2)

for i in a:
    co = ls[int(i)]
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

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

c = collections.Counter(a)

comon = c.most_common()
ans = 0

for i in c.values():
  if i != 1:
  	ans += (i*(i-1)//2)

for i in a:
    for j in comon:
      if i == j[0]:
        co = j[1]
        break
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

      

Fixed submission:
import collections
n = int(input())
a = list(map(str,input().split()))
ls = [i for i in range(2*10**5)]
c = collections.Counter(a)
comon = c.most_common()
ans = 0

for i in comon:
    if i != 1:
      ls[int(i[0])] = i[1]
      ans += (i[1]*(i[1]-1)//2)

for i in a:
    co = ls[int(i)]
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

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

c = collections.Counter(a)

comon = c.most_common()
ans = 0

for i in comon:
  if i[1] != 1:
  	ans += (i[1]*(i[1]-1)//2)
  
for i in a:
    for j in comon:
      if i == j[0]:
        co = j[1]
        break
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

      

Fixed submission:
import collections
n = int(input())
a = list(map(str,input().split()))
ls = [i for i in range(2*10**5)]
c = collections.Counter(a)
comon = c.most_common()
ans = 0

for i in comon:
    if i != 1:
      ls[int(i[0])] = i[1]
      ans += (i[1]*(i[1]-1)//2)

for i in a:
    co = ls[int(i)]
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

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

c = collections.Counter(a)

comon = c.most_common()
ans = 0
for i in comon:
  if i[1] != 1:
  	ans += (i[1]*(i[1]-1)//2)
  
for i in a:
    for j in comon:
      if i == j[0]:
        co = j[1]
        break
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

      

Fixed submission:
import collections
n = int(input())
a = list(map(str,input().split()))
ls = [i for i in range(2*10**5)]
c = collections.Counter(a)
comon = c.most_common()
ans = 0

for i in comon:
    if i != 1:
      ls[int(i[0])] = i[1]
      ans += (i[1]*(i[1]-1)//2)

for i in a:
    co = ls[int(i)]
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

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

c = collections.Counter(a)

comon = c.most_common()
ans = 0
for i in comon:
  if i[1] != 1:
  	ans += (i[1]*(i[1]-1)//2)
  
for i in a:
  if (ans-int(a.count(i))) < 0:
    print(0)
  else:
    for j in comon:
      if i == j[0]:
        co = j[1]
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

      

Fixed submission:
import collections
n = int(input())
a = list(map(str,input().split()))
ls = [i for i in range(2*10**5)]
c = collections.Counter(a)
comon = c.most_common()
ans = 0

for i in comon:
    if i != 1:
      ls[int(i[0])] = i[1]
      ans += (i[1]*(i[1]-1)//2)

for i in a:
    co = ls[int(i)]
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

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

c = collections.Counter(a)

comon = c.most_common()
ans = 0
for i in comon:
  if i[1] != 1:
  	ans += (i[1]*(i[1]-1)//2)
  
for i in a:
  if (ans-int(a.count(i))) < 0:
    print(0)
  else:
    co = a.count(i)
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))


      

Fixed submission:
import collections
n = int(input())
a = list(map(str,input().split()))
ls = [i for i in range(2*10**5)]
c = collections.Counter(a)
comon = c.most_common()
ans = 0

for i in comon:
    if i != 1:
      ls[int(i[0])] = i[1]
      ans += (i[1]*(i[1]-1)//2)

for i in a:
    co = ls[int(i)]
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))

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

comon = c.most_common()
ans = 0
for i in comon:
  if i[1] != 1:
  	ans += (i[1]*(i[1]-1)//2)
  
for i in a:
  if (ans-int(a.count(i))) < 0:
    print(0)
  else:
    co = a.count(i)
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))


      

Fixed submission:
import collections
n = int(input())
a = list(map(str,input().split()))
ls = [i for i in range(2*10**5)]
c = collections.Counter(a)
comon = c.most_common()
ans = 0

for i in comon:
    if i != 1:
      ls[int(i[0])] = i[1]
      ans += (i[1]*(i[1]-1)//2)

for i in a:
    co = ls[int(i)]
    print(ans-(co*(co-1)//2)+((co-1)*(co-2)//2))