Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
n = int(input())
s = list(map(int,input().split()))
ans = {}
#各番号がいくつずつあるのかを整理
#keyに番号、valueにその番号が書かれてあるボールの数
for i in range(n):
    if not s[i] in ans.keys():
        ans[s[i]] = 1
    else:
        ans[s[i]] += 1
#iC2の総和
answer = 0
for i,j in ans.items():
    answer += j*(j-1)//2
#answer-nC2+(n-1)C2 = answer-n+1
#nはans[s[i]],よって以下の出力で求められる
for i in range(n):
    print(answer-ans[s[i]]+1)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
List={}
x=0
for i in range(n):
    if not a[i] in List:
        List[a[i]] = 1
    else:
        List[a[i]]+=1
    
sigma=0
 
for key,item in List.items():
    sigma += item*(item-1)//2
for i in range(n):
    print(sigma-List[a[i]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
n = int(input())
s = list(map(int,input().split()))
ans = {}
#各番号がいくつずつあるのかを整理
#keyに番号、valueにその番号が書かれてあるボールの数
for i in range(n):
    if not s[i] in ans.keys():
        ans[s[i]] = 1
    else:
        ans[s[i]] += 1
#iC2の総和
answer = 0
for i,j in ans.items():
    answer += j*(j-1)//2
#answer-nC2+(n-1)C2 = answer-n+1
#nはans[s[i]],よって以下の出力で求められる
for i in range(n):
    print(answer-ans[s[i]]+1)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
List={}
x=0
for i in range(n):
    if not a[i] in List:
        List[a[i]] = 1
    else:
        List[a[i]]+=1
    
sigma=0
 
for key,item in List.items():
    sigma += item*(item-1)//2
for i in range(n):
    print(sigma-List[a[i]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
n = int(input())
s = list(map(int,input().split()))
ans = {}
#各番号がいくつずつあるのかを整理
#keyに番号、valueにその番号が書かれてあるボールの数
for i in range(n):
    if not s[i] in ans.keys():
        ans[s[i]] = 1
    else:
        ans[s[i]] += 1
#iC2の総和
answer = 0
for i in ans.values():
    answer += i*(i-1)//2
#answer-nC2+(n-1)C2 = answer-n+1
#nはans[s[i]],よって以下の出力で求められる
for i in range(n):
    print(answer-ans[s[i]]+1)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
List={}
x=0
for i in range(n):
    if not a[i] in List:
        List[a[i]] = 1
    else:
        List[a[i]]+=1
    
sigma=0
 
for key,item in List.items():
    sigma += item*(item-1)//2
for i in range(n):
    print(sigma-List[a[i]]+1)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n = int(input())
s = list(map(int,input().split()))
ans = {}
#各番号がいくつずつあるのかを整理
#keyに番号、valueにその番号が書かれてあるボールの数
for i in range(n):
    if not　s[i] in ans.keys():
        ans[s[i]] = 1
    else:
        ans[s[i]] += 1
#iC2の総和
answer = 0
for i in ans.values():
    answer += i
#answer-nC2+(n-1)C2 = answer-n+1
#nはans[s[i]],よって以下の出力で求められる
for i in range(n):
    print(answer-ans[s[i]]+1)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
List={}
x=0
for i in range(n):
    if not a[i] in List:
        List[a[i]] = 1
    else:
        List[a[i]]+=1
    
sigma=0
 
for key,item in List.items():
    sigma += item*(item-1)//2
for i in range(n):
    print(sigma-List[a[i]]+1)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n = int(input())
s = list(map(int,input().split()))
ans = {}
#各番号がいくつずつあるのかを整理
#keyに番号、valueにその番号が書かれてあるボールの数
for i in range(n):
    if s[i] in ans.keys():
        ans[s[i]] = 1
    else:
        ans[s[i]] += 1
#iC2の総和 
answer = 0
for i in ans.values():
    answer += i
#answer-nC2+(n-1)C2 = answer-n+1
#nはans[s[i]],よって以下の出力で求められる
for i in range(n):
    print(answer-ans[s[i]]+1)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
List={}
x=0
for i in range(n):
    if not a[i] in List:
        List[a[i]] = 1
    else:
        List[a[i]]+=1
    
sigma=0
 
for key,item in List.items():
    sigma += item*(item-1)//2
for i in range(n):
    print(sigma-List[a[i]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
n = int(input())
s = list(map(int,input().split()))
ans = {}
a = []
sub = {}
answer = 0
a_append = a.append
for i in s:
    if not i in a:
        ans[i] = s.count(i)*(s.count(i)-1)//2
        a_append(i)
        sub[i] = (s.count(i)-2)*(s.count(i)-1)//2
        answer += ans[i]
#print(ans)

#print(answer)
for i in range(n):
    print(answer-ans[s[i]]+sub[s[i]])

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
List={}
x=0
for i in range(n):
    if not a[i] in List:
        List[a[i]] = 1
    else:
        List[a[i]]+=1
    
sigma=0
 
for key,item in List.items():
    sigma += item*(item-1)//2
for i in range(n):
    print(sigma-List[a[i]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
n = int(input())
s = list(map(int,input().split()))
ans = {}
a = []
sub = {}
answer = 0
for i in s:
    if not i in a:
        ans[i] = s.count(i)*(s.count(i)-1)//2
        a.append(i)
        sub[i] = (s.count(i)-2)*(s.count(i)-1)//2
        answer += ans[i]
#print(ans)

#print(answer)
for i in range(n):
    print(answer-ans[s[i]]+sub[s[i]])

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
List={}
x=0
for i in range(n):
    if not a[i] in List:
        List[a[i]] = 1
    else:
        List[a[i]]+=1
    
sigma=0
 
for key,item in List.items():
    sigma += item*(item-1)//2
for i in range(n):
    print(sigma-List[a[i]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
n = int(input())
s = list(map(int,input().split()))
ans = {}
a = []
answer = 0
for i in s:
    if not i in a:
        ans[i] = s.count(i)*(s.count(i)-1)//2
        a.append(i)
        answer += ans[i]
#print(ans)

#print(answer)
for i in range(n):
    print(answer-ans[s[i]]+((ans[s[i]]*2//s.count(s[i]))*(s.count(s[i])-2)//2)) 


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
List={}
x=0
for i in range(n):
    if not a[i] in List:
        List[a[i]] = 1
    else:
        List[a[i]]+=1
    
sigma=0
 
for key,item in List.items():
    sigma += item*(item-1)//2
for i in range(n):
    print(sigma-List[a[i]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
n = int(input())
s = list(map(int,input().split()))
ans = {}
a = []
for i in s:
    if not i in a:
        ans[i] = s.count(i)*(s.count(i)-1)//2
        a.append(i)
#print(ans)
answer = 0
for i in ans.values():
    answer += i
#print(answer)
for i in range(n):
    print(answer-ans[s[i]]+((ans[s[i]]*2//s.count(s[i]))*(s.count(s[i])-2)//2))   


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
List={}
x=0
for i in range(n):
    if not a[i] in List:
        List[a[i]] = 1
    else:
        List[a[i]]+=1
    
sigma=0
 
for key,item in List.items():
    sigma += item*(item-1)//2
for i in range(n):
    print(sigma-List[a[i]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
n = int(input())
s = list(map(int,input().split()))
for i in range(n):
    ans = 0
    #print("a")
    a = []
    for j,k in enumerate(s):
        if j == i:
            continue
        elif not k in a:
            if s[i] == k:
                p = (s.count(k)-2)*(s.count(k)-1)
                ans += p//2
            else:
                p = s.count(k)*(s.count(k)-1)
                ans += p//2
            a.append(k)
            #print(ans,p,j)
#    print(s)
    print(ans)        


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
List={}
x=0
for i in range(n):
    if not a[i] in List:
        List[a[i]] = 1
    else:
        List[a[i]]+=1
    
sigma=0
 
for key,item in List.items():
    sigma += item*(item-1)//2
for i in range(n):
    print(sigma-List[a[i]]+1)