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

dic = {}
ans = 0
for t in A:
    if t in dic.keys():
        continue
    tmp = A.count(t)
    dic[t] = tmp
    ans += tmp*(tmp-1)//2

for a in A:
    val = dic.get(a)
    print(ans-val+1)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

dic = {}
ans = 0
# for t in A:
#     if t in dic.keys():
#         continue
#     tmp = A.count(t)
#     dic[t] = tmp
#     ans += tmp*(tmp-1)//2

for a in A:
    tmp = dic.get(a)
    if tmp == None:
        dic[a] = 1
    else:
        dic[a] = tmp + 1

for key in list(dic.keys()):
    tmp = dic.get(key)
    ans += tmp * (tmp - 1) // 2
    

for a in A:
    val = dic.get(a)
    print(ans-val+1)

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


dic = {}
ans = 0
prev = -1
for t in sorted(A):
    # if t in dic.keys():
    #     continue
    if prev == t:
        continue
    tmp = A.count(t)
    dic[t] = tmp
    ans += tmp * (tmp - 1) // 2
    prev = t

for i in range(N):
    val = dic.get(A[i])
    print(ans-val+1)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

dic = {}
ans = 0
# for t in A:
#     if t in dic.keys():
#         continue
#     tmp = A.count(t)
#     dic[t] = tmp
#     ans += tmp*(tmp-1)//2

for a in A:
    tmp = dic.get(a)
    if tmp == None:
        dic[a] = 1
    else:
        dic[a] = tmp + 1

for key in list(dic.keys()):
    tmp = dic.get(key)
    ans += tmp * (tmp - 1) // 2
    

for a in A:
    val = dic.get(a)
    print(ans-val+1)

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


dic = {}
ans = 0
for t in A:
    if t in dic.keys():
        continue
    tmp = A.count(t)
    dic[t] = tmp
    ans += tmp*(tmp-1)//2

for i in range(N):
    val = dic.get(A[i])
    print(ans-val+1)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

dic = {}
ans = 0
# for t in A:
#     if t in dic.keys():
#         continue
#     tmp = A.count(t)
#     dic[t] = tmp
#     ans += tmp*(tmp-1)//2

for a in A:
    tmp = dic.get(a)
    if tmp == None:
        dic[a] = 1
    else:
        dic[a] = tmp + 1

for key in list(dic.keys()):
    tmp = dic.get(key)
    ans += tmp * (tmp - 1) // 2
    

for a in A:
    val = dic.get(a)
    print(ans-val+1)

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


dic = {}
ans = 0
for t in A:
    if t in dic.keys():
        continue
    tmp = A.count(t)
    dic[t] = tmp
    ans += tmp*(tmp-1)//2

for i in range(N):
    val = dic.get(A[i])
    print(ans-val+1)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

dic = {}
ans = 0
# for t in A:
#     if t in dic.keys():
#         continue
#     tmp = A.count(t)
#     dic[t] = tmp
#     ans += tmp*(tmp-1)//2

for a in A:
    tmp = dic.get(a)
    if tmp == None:
        dic[a] = 1
    else:
        dic[a] = tmp + 1

for key in list(dic.keys()):
    tmp = dic.get(key)
    ans += tmp * (tmp - 1) // 2
    

for a in A:
    val = dic.get(a)
    print(ans-val+1)

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


dic = {}
ans_dic = {}
for t in A:
    tmp = A.count(t)
    dic[t] = tmp
    ans_dic[t] = tmp * (tmp - 1) // 2
    
# print(dic)
# print(ans_dic)
ans = sum(ans_dic.values())
# print(ans)
for i in range(N):
    val = dic.get(A[i])
    print(ans-val+1)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

dic = {}
ans = 0
# for t in A:
#     if t in dic.keys():
#         continue
#     tmp = A.count(t)
#     dic[t] = tmp
#     ans += tmp*(tmp-1)//2

for a in A:
    tmp = dic.get(a)
    if tmp == None:
        dic[a] = 1
    else:
        dic[a] = tmp + 1

for key in list(dic.keys()):
    tmp = dic.get(key)
    ans += tmp * (tmp - 1) // 2
    

for a in A:
    val = dic.get(a)
    print(ans-val+1)

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


dic = {}
for t in A:
    dic[t] = A.count(t)

ans_dict = {}
for i in list(dic.keys()):
    ans = 0
    for key in list(dic.keys()):
        val = dic.get(key)
        if i == key:
            val -= 1
        ans += val * (val - 1) // 2
    ans_dict[i] = ans

# print(ans_dict)

for i in range(N):
    print(ans_dict.get(A[i]))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

dic = {}
ans = 0
# for t in A:
#     if t in dic.keys():
#         continue
#     tmp = A.count(t)
#     dic[t] = tmp
#     ans += tmp*(tmp-1)//2

for a in A:
    tmp = dic.get(a)
    if tmp == None:
        dic[a] = 1
    else:
        dic[a] = tmp + 1

for key in list(dic.keys()):
    tmp = dic.get(key)
    ans += tmp * (tmp - 1) // 2
    

for a in A:
    val = dic.get(a)
    print(ans-val+1)

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

# ans = []
# for i in range(N):

tmp = sorted(A)
dic = {}
for t in tmp:
    dic[t] = tmp.count(t)

# print(dic)

for i in range(N):
    # tmp = dic.get(A[i])
    ans = 0
    for key in list(dic.keys()):
        val = dic.get(key)
        if key == A[i]:
            val -= 1
        # print(key)
        # print(val)
        # print("\t"+str(val * (val - 1) // 2))
        ans += val * (val - 1) // 2
    print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))

dic = {}
ans = 0
# for t in A:
#     if t in dic.keys():
#         continue
#     tmp = A.count(t)
#     dic[t] = tmp
#     ans += tmp*(tmp-1)//2

for a in A:
    tmp = dic.get(a)
    if tmp == None:
        dic[a] = 1
    else:
        dic[a] = tmp + 1

for key in list(dic.keys()):
    tmp = dic.get(key)
    ans += tmp * (tmp - 1) // 2
    

for a in A:
    val = dic.get(a)
    print(ans-val+1)