Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

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

def find_next_true(ind, bools, N):
    for i in range(ind+1, N):
        if bools[i]:
            return i
    return N

def Main(N, A):
    A.sort()
    bools = [True]*N
    i = 0
    j = 0
    while i < N:
        j = find_next_true(i, bools, N)
        while j < N:
            div, mod = divmod(A[j], A[i])
            if mod == 0:
                bools[j] = False
                if div == 1:
                    bools[i] = False
            j = find_next_true(j, bools, N)
        i = find_next_true(i, bools, N)
    return bools.count(True)

print(Main(N, A))

### FIXED CODE ###

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


from collections import Counter
def Main(N, A):
    A.sort()
    amax = A[-1]+1
    d = {}
    for i in range(1, amax):
        d[i] = 0
    for a in A:
        i = 1
        while a*i < amax:
            d[a*i] += 1
            i += 1
    ans = 0
    for a in A:
        if d[a] == 1:
            ans += 1
    return ans

print(Main(N, A))
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.readline

def main():
    order_F = []
    order_F = input().rstrip().split('T')
    x, y = map(int, input().split())
    distance = [len(i) for i in order_F]
    side = []
    vert = []
    side.append(distance[0])
    vert.append(0)
    for i in range(1, len(distance)):
        if i%2 == 0:
            tmp = [j for j in side]
            for j, value in enumerate(tmp):
                side[j] = value + distance[i]
                side.append(value - distance[i])
        else:
            tmp = [j for j in vert]
            for j, value in enumerate(tmp):
                vert[j] = value + distance[i]
                vert.append(value - distance[i])
    if x in side and y in vert:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.readline

def main():
    order_F = []
    order_F = input().rstrip().split('T')
    x, y = map(int, input().split())
    vert_DP = [False] * 8001
    side_DP = [False] * 8001
    vert_DP[0] = True
    side_DP[0] = True
    vert_sum = 0
    side_sum = 0
    distance = [len(order_F[i]) for i in range(len(order_F))]
    order_len = len(order_F)
    x -= len(order_F[0])
    vert_last = 0
    side_last = 0
    for i in range(1, order_len):
        if i % 2 == 0:
            side_sum += distance[i]
            for j in reversed(range(side_last+1)):
                if side_DP[j]:
                    side_DP[j + distance[i]] = True
            side_last += distance[i]
        else:
            vert_sum += distance[i]
            for j in reversed(range(vert_last+1)):
                if vert_DP[j]:
                    vert_DP[j + distance[i]] = True
            vert_last += distance[i]
    if side_sum < x or vert_sum < y:
        print("No")
    elif (side_sum - x) % 2 == 1 or (vert_sum - y) % 2 == 1:
        print("No")
    else:
        if side_DP[(side_sum - x)//2] and vert_DP[(vert_sum - y)//2]:
            print("Yes")
        else:
            print("No")

if __name__ == "__main__":
    main()
### BUGGY CODE ###

N = int(input())

f_x = 0
sum = 0

for i in range(1,N+1):
    for j in range(1,i+1):
        if i%j == 0:
            f_x += 1
    sum += i*f_x
    f_x = 0

print(sum)

### FIXED CODE ###

N = int(input())

sum = 0

for j in range(1,N+1):
    k = N//j
    sum += (1+k)*k*j//2
print(sum)
### BUGGY CODE ###

K = int(input())

nana = 7
count = 1

mod = 7 % K 

past = [mod]

while mod != 0:
  mod = (mod * 10 + 7) % K
  if mod in past:
    break
  past.append(mod)
  count += 1
  
if mod == 0:
  print(count)
else:
  print(-1)
  
 

### FIXED CODE ###

K = int(input())

nana = 7
count = 1

mod = 7 % K 

past = {mod}

while mod != 0:
  mod = (mod * 10 + 7) % K
  if mod in past:
    break
  past.add(mod)
  count += 1
  
if mod == 0:
  print(count)
else:
  print(-1)
### BUGGY CODE ###

N=int(input())
m=3500
for I in range(1,m**2):
    n=I//m
    h=I%m
    A=N*h*n
    B=4*h*n-N*n-N*h
    if B<=0:
        continue
    if A%B==0:
        print(h,n,A//B)
        exit()

### FIXED CODE ###

s=int(input());
for n in range(1,3501):
    for h in range(1,3501):
        x=4*h*n-s*n-s*h
        if x>0:
            if ((s*h*n)/x).is_integer():
                print(int((s*h*n)/x),h,n)
                exit()
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
total=sum(A)
for i in range(Q):
    B, C = map(int, input().split())
    for j in range(N):
        if A[j]==B:
            total=total-B+C
            A[j]=C
    print(total)


### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
total=sum(A)
A=Counter(A)
for i in range(Q):
    B, C = map(int, input().split())
    total=total-(A[B]*B)+(C*A[B])
    A[C] = A[C]+A[B]
    A[B]=0
    print(total)
### BUGGY CODE ###


import collections

n = int(input())
a = list(map(int, input().split()))
c_lst = []
c = collections.Counter(a)
c_lst = c.most_common()

values, counts = zip(*c_lst)

cnt = []
for i in range(len(c_lst)):
    cnt.append((c_lst[i][1] * (c_lst[i][1] - 1)) // 2)
cnt_ = sum(cnt)
    
for i in a:
    ans = 0
    ans += ((c_lst[values.index(i)][1] - 1) * (c_lst[values.index(i)][1] - 2)) // 2
    ans += cnt_ - cnt[values.index(i)]
    print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
cnt = [0] * n
for i in a:
    cnt[i-1] += 1
total = [0] * n
for i in range(n):
    total[i] = cnt[i] * (cnt[i] - 1) // 2
total_sum = sum(total)
for i in a:
    ans = total_sum
    ans -= total[i-1]
    ans += (cnt[i-1] - 1) * (cnt[i-1] - 2) // 2
    print(ans)
### BUGGY CODE ###

N=int(input())
L=list(map(int,input().split()))
L=sorted(L)
count=0
while len(L)>=3:
  a=L.pop()
  for i in range(len(L)-1):
    for j in range(i+1,len(L)):
      if a<L[i]+L[j]:
        count+=1
print(count)

### FIXED CODE ###

import bisect
 
N=int(input())
L=list(map(int,input().split()))
 
L.sort()
count=0
for i in range(N):
  for j in range(i+1,N):
    c=L[i]+L[j]
    index=bisect.bisect_left(L,c)
    count+=max(0,index-j-1)
print(count)
### BUGGY CODE ###

X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

temp = P[:X] + Q[:Y]

temp.sort()
ans = sum(temp)
for ri in R:
    if temp[0] < ri:
        ans += ri - temp[0]
        temp.pop(0)
    else:
        break

print(ans)

### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)

temp = P[:X] + Q[:Y] + R

temp.sort(reverse=True)
ans = sum(temp[:X+Y])

print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)

def dfs(v,p):
    if res_v[v]!=-1:
        return res_v[v]
    size[v]=len(G[v])
    dp[v]=[0]*size[v]
    res=1
    for i in range(size[v]):
        nv=G[v][i]
        if nv==p:
            p_i[v]=i
            continue
        R=dfs(nv,v)
        dp[v][i]=R
        res=res*(R+1)%MOD
    return res
    
def reroot(v,res_p,p):
    if p!=-1:
        dp[v][p_i[v]]=res_p
    for i in range(size[v]):
        ans[v]=ans[v]*(dp[v][i]+1)%MOD
    dp_L=[1]*(size[v]+1)
    dp_R=[1]*(size[v]+1)
    for i in range(size[v]):
        dp_L[i+1]=dp_L[i]*(dp[v][i]+1)%MOD
    for i in reversed(range(size[v])):
        dp_R[i]=dp_R[i+1]*(dp[v][i]+1)%MOD
        
    for i in range(size[v]):
        nv=G[v][i]
        if nv==p:
            continue
        reroot(nv,dp_L[i]*dp_R[i+1]%MOD,v)

N,MOD=map(int,input().split())
G=[[] for i in range(N)]
for i in range(N-1):
    x,y=map(lambda x:int(x)-1,input().split())
    G[x].append(y)
    G[y].append(x)
res_v=[-1]*N
dp=[[] for i in range(N)]
size=[-1]*N
p_i=[-1]*N
dp_L=[[] for i in range(N)]
dp_R=[[] for i in range(N)]
ans=[1]*N

z_root=dfs(0,-1)
res_v[0]=z_root
reroot(0,0,-1)
print(*ans,sep='\n')


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
input=sys.stdin.readline
def dfs(v,p):
    if res_v[v]!=-1:
        return res_v[v]
    size[v]=len(G[v])
    dp[v]=[0]*size[v]
    res=1
    for i in range(size[v]):
        nv=G[v][i]
        if nv==p:
            p_i[v]=i
            continue
        R=dfs(nv,v)
        dp[v][i]=R
        res=res*(R+1)%MOD
    return res
    
def reroot(v,res_p,p):
    if p!=-1:
        dp[v][p_i[v]]=res_p
    for i in range(size[v]):
        ans[v]=ans[v]*(dp[v][i]+1)%MOD
    dp_L=[1]*(size[v]+1)
    dp_R=[1]*(size[v]+1)
    for i in range(size[v]):
        dp_L[i+1]=dp_L[i]*(dp[v][i]+1)%MOD
    for i in reversed(range(size[v])):
        dp_R[i]=dp_R[i+1]*(dp[v][i]+1)%MOD
        
    for i in range(size[v]):
        nv=G[v][i]
        if nv==p:
            continue
        reroot(nv,dp_L[i]*dp_R[i+1]%MOD,v)

N,MOD=map(int,input().split())
G=[[] for i in range(N)]
for i in range(N-1):
    x,y=map(lambda x:int(x)-1,input().split())
    G[x].append(y)
    G[y].append(x)
res_v=[-1]*N
dp=[[] for i in range(N)]
size=[-1]*N
p_i=[-1]*N
dp_L=[[] for i in range(N)]
dp_R=[[] for i in range(N)]
ans=[1]*N

z_root=dfs(0,-1)
res_v[0]=z_root
reroot(0,0,-1)
print(*ans,sep='\n')
### BUGGY CODE ###

N,D,A = map(int,input().split())
d = {}
E = []
import math
for i in range(N):
    x,h = map(int,input().split())
    n = math.ceil(h/A)
    d[x] = n
    E.append(x)
E.sort()
ans = 0
import bisect
while E:
    x = E.pop(0)
    if d[x] <= 0:
        continue
    y = bisect.bisect_right(E,x+2*D)
    z = d[x]
    ans += z
    for k in range(y):
        d[E[k]] -= z 
print(ans)

### FIXED CODE ###

N,D,A = map(int,input().split())
attack_number = {}
Enemy = []
import math
for i in range(N):
    x,h = map(int,input().split())
    n = math.ceil(h/A)
    attack_number[x] = n
    Enemy.append(x)
Enemy.sort()
bomb_number = [0 for i in range(N+1)]
F = {}
import bisect
for i in range(N):
    x = Enemy[i]
    y = bisect.bisect_right(Enemy,x+2*D)
    F[i] = y
ans = 0
for i in range(N):
    if i > 0:
        bomb_number[i] += bomb_number[i-1]
    x = attack_number[Enemy[i]] - bomb_number[i]
    if x <= 0:
        continue
    y = F[i]
    bomb_number[i] += x
    bomb_number[y] -= x
    ans += x
print(ans)
### BUGGY CODE ###

# D - Multiple of 2019
s = input()[::-1]
length = len(s)
a = []
d = []

for i in range(length):
    a.append(int(s[i]) * pow(10, i) % 2019)
d.append(a[0])
for i in range(length-1):
    d.append((d[i] + a[i+1]) % 2019)
cnt = sum(d[i] == d[j] for i in range(length-1) for j in range(i+1, length))
print(cnt + d.count(0))

### FIXED CODE ###

import numpy as np

s = input()[::-1]
length = len(s)
a = np.zeros(length, dtype=int)
d = np.zeros(length, dtype=int)
ans = np.zeros(2019, dtype=int)
x = 10

a[0] = int(s[0])
d[0] = a[0]
ans[d[0]] += 1

for i in range(1, length):
    a[i] = int(s[i]) * x % 2019
    d[i] = (d[i-1] + a[i]) % 2019
    ans[d[i]] += 1
    x = x * 10 % 2019

ans_c = ans[np.nonzero(ans)]

print(int(sum([ans_c[i] * (ans_c[i]-1) for i in range(ans_c.shape[0])]) / 2) + ans[0])
### BUGGY CODE ###

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

for i in range(1, n + 1):
	#	print(i)
	print(numlist.count(i))


### FIXED CODE ###

n = int(input())
numlist = list(map(int, input().split()))
# print(numlist)
result = [0] * n
# print(result)

for i in numlist:
	result[i - 1] = result[i - 1] + 1

for j in range(len(result)):
	print(result[j])
# for i in range(1, n + 1):
#	print(numlist.count(i))
### BUGGY CODE ###

import sys, heapq
input = sys.stdin.readline
n, q = map(int, input().split())
c = list(map(int, input().split()))


que = []
for i in range(q):
    l, r = map(int, input().split())
    heapq.heappush(que, (r, l, i))

bit = [0 for _ in range(n+1)]
def sum(i):
    s = 0
    while i > 0:
        s += bit[i]
        i -= (i & -i)
    return s
def add(i, x):
    while i <= n:
        bit[i] += x
        i += (i & -i)


lastAppeared = [-1 for _ in range(n+1)]
ans = [None for _ in range(q)]
for i in range(1, n+1):
    if lastAppeared[c[i-1]] != -1:
        add(lastAppeared[c[i-1]], -1)
    lastAppeared[c[i-1]] = i
    add(i, 1)

    while len(que) > 0 and que[0][0] == i:
        r, l, x = heapq.heappop(que)
        ans[x] = sum(r) - sum(l-1)

    
print(*ans, sep='\n')


### FIXED CODE ###

import sys, heapq
input = sys.stdin.readline
n, q = map(int, input().split())
c = [int(x) - 1 for x in input().split()]

que = []
for i in range(q):
    l, r = map(int, input().split())
    que.append((l, r, i))



class SegTree(object):
    def __init__(self, n):
        self.BIT = [0] * (n + 1)
        self.num = n

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.BIT[i]
            i -= i & (-i)
        return s

    def add(self, i, x):
        while i <= self.num:
            self.BIT[i] += x
            i += i & (-i)
    

que.sort(key=lambda x: -x[1])
ans = [None] * q
last = [-1] * n
BIT = SegTree(n)

for i in range(1, n+1):
    if last[c[i-1]] != -1:
        BIT.add(last[c[i-1]], -1)
    last[c[i-1]] = i
    BIT.add(i, 1)

    while que and que[-1][1] == i:
        l, r, x = que.pop()
        ans[x] = BIT.sum(r) - BIT.sum(l-1)

print(*ans, sep='\n')
### BUGGY CODE ###

num = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

for k in range(num):
    a_rotate_k = []
    for i in range(num):
        a_rotate_k.append(a[(i+k) % num])
        
    for i in range(1, num):
        if a_rotate_k[i] ^ b[i] != a_rotate_k[0] ^ b[0]:
            break
    else:
        print(k, a_rotate_k[0] ^ b[0])

### FIXED CODE ###

num = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
d = []

for i in range(num):
    c.append(a[i] ^ a[(i+1)%num])
    d.append(b[i] ^ b[(i+1)%num])
    
c += c

# print(c)
# print(d)

# テーブル作成
table = [0]
k = 0
for i in range(1, num+1):
    table.append(k)
    if i == num:
        continue
    
    if d[i] == d[k]:
        k += 1
    else:
        k = 0

# print(table)

i = 0 # 探索される文字列の位置
j = 0 # 探索する文字列の位置
k = 0 # kの初期値
while k < num:
    
    while True:
        # print(i, j, k)
        if c[i] == d[j]:
            if j == num - 1:
                print(k, a[k] ^ b[0])
                i += 1
                j = table[num]
                k = i - j
                break
            
            i += 1
            j += 1
        elif j != 0:
            j -= 1
        else:    
            i += 1
            j = table[j]
            break
    
    k = i - j
### BUGGY CODE ###

import queue

def resolve():
    # ★get input
    h, w = map(int, input().split())

    grid = [["" for i in range(w)] for j in range(h)]

    for i in range(h):
        line = input()
        for j in range(w):
            grid[i][j] = line[j:j+1]

    # ★exec
    # BFSにて最短経路を求める
    # 準備
    distance = [[-1 for i in range(w)] for j in range(h)]
    que = queue.Queue()

    # スタート地点の情報を設定
    # 多点スタートの設定
    for i in range(h):
        for j in range(w):
            if grid[i][j] == "#":
                que.put([i, j])
                distance[i][j] = 0

    # BFS開始
    while not que.empty():

        now = que.get()

        # 上下左右のマスを確認
        for move_y, move_x in ((1, 0), (-1, 0), (0, 1), (0, -1)):

            # 盤の範囲外なら何もしない
            target = [now[0] + move_y, now[1] + move_x]
            if not h > target[0] >= 0 or not w > target[1] >= 0:
                continue

            # 黒塗りされているなら何もしない
            if grid[target[0]][target[1]] == '#':
                continue

            # 距離が設定済みなら何もしない
            if not distance[target[0]][target[1]] == -1:
                continue

            # キューに追加
            que.put(target)

            # 最短距離を設定
            distance[target[0]][target[1]] = distance[now[0]][now[1]] + 1

    # 距離が最大の点 = 答えになる。
    ans = 0
    for i in range(h):
        ans = max(ans, max(distance[i]))

    print(ans)


if __name__ == "__main__":
    resolve()

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
grid = [input() for i in range(H)]

# 初期の黒('#')の位置からの距離
dist = [[-1]*W for _ in range(H)]

# '#'の位置をキューに追加（＝今回はこれが複数あるので、複数スタートとなる）
black_cells = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            black_cells.append((h, w))
            dist[h][w] = 0

def bfs(black_cells, dist):
    """
    BFSを用いて、全マス目を黒くする回数を求める

    Args:
        black_cells: 「開始時の黒マス」の座標が入ったキュー（複数座標あり）
        dist: 「開始時の黒マス」からの距離の入ったリスト  [[-1, -1, 0], ...]
        　　　（白マスの初期値は0）

    Returns:
        g: 操作を繰り返した数
    """
    d = 0
    while black_cells:
        # キューとして使うのでpop()ではなくpopleft()
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:  # セルが白('.')であるのと同義
                dist[new_h][new_w] = d+1
                black_cells.append((new_h, new_w))
    return d

d = bfs(black_cells, dist)
print(d)
### BUGGY CODE ###

# https://atcoder.jp/contests/abc122/tasks/abc122_c
# C - GeT AC

n, q = list(map(int, input().split()))
s = input().split()[0]
lr_list = []

for _ in range(q):
    l, r = list(map(int, input().split()))
    lr_list.append((l, r))

count_ac_list = []
for i in range(n):
    count_ac_list.append(s[:i+1].count('AC'))

# print(count_ac_list)

for l, r in lr_list:
    if l > 1:
        count = count_ac_list[r-1] - count_ac_list[l-1]
    else:
        count = count_ac_list[r-1]
    print(count)


### FIXED CODE ###

n, q = list(map(int, input().split()))
s = input().split()[0]
lr_list = [list(map(int, input().split())) for _ in range(q)]

count_ac_list = [0] * n
for i in range(n-1):
    # print('{}: {}'.format(i, s[i:i+2]))
    if s[i:i+2] == 'AC':
        count_ac_list[i+1] = count_ac_list[i] + 1
    else:
        count_ac_list[i+1] = count_ac_list[i]

count_list = [str(count_ac_list[r-1] - count_ac_list[l-1]) for l, r in lr_list]

print('\n'.join(count_list))
### BUGGY CODE ###

from operator import mul
from functools import reduce

N = input()
s = input().split()
k = [int(_) for _ in s] 
y = reduce(mul, k)

if y <= 10**18:
    print(y)
else:
    print(-1)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 1
if 0 in a:
  print(0)
else:
  for i in range(n):
    ans *= a[i]
    if ans > 10**18:
      print(-1)
      break
    if i == n-1:
      print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
D - Practical Skill Test
https://beta.atcoder.jp/contests/abc089/tasks/abc089_d

"""
import sys
from sys import stdin
from functools import lru_cache
input = stdin.readline


@lru_cache(maxsize=None)
def sub_solve(l, r, D):
    sx, sy = numbers[l]
    ans = 0
    while True:
        if l == r:
            break
        gx, gy = numbers[l+D]
        ans += abs(sx - gx) + abs(sy - gy)
        l += D
        sx, sy = gx, gy
    return ans


def solve(numbers, queries, D):
    for l, r in queries:
        ans = sub_solve(l, r, D)
        print(ans)


numbers = dict()
def main(args):
    global numbers
    H, W, D = map(int, input().split())
    board = []
    for _ in range(H):
        board.append([int(x) for x in input().split()])
    Q = int(input())
    queries = []
    for _ in range(Q):
        queries.append([int(x) for x in input().split()])

    for y, row in enumerate(board, start=1):
        for x, i in enumerate(row, start=1):
            numbers[i] = [x, y]

    solve(numbers, queries, D)


if __name__ == '__main__':
    main(sys.argv[1:])
    


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
D - Practical Skill Test
https://beta.atcoder.jp/contests/abc089/tasks/abc089_d

"""
import sys
from sys import stdin
input = stdin.readline


def sub_solve(l, r):
    sx, sy = numbers[l]
    gx, gy = numbers[r]
    return abs(sx - gx) + abs(sy - gy)


def solve(queries, H, W, D):
    dp = [0] * (H*W+1)
    for i in range(D+1, H*W+1):
        dp[i] = dp[i-D] + sub_solve(i-D, i)

    for l, r in queries:
        ans = dp[r] - dp[l]
        print(ans)


numbers = dict()
def main(args):
    global numbers
    H, W, D = map(int, input().split())

    for y in range(1, H+1):
        tmp = [int(x) for x in input().split()]
        for x, i in enumerate(tmp, start=1):
            numbers[i] = (x, y)

    Q = int(input())
    queries = []
    for _ in range(Q):
        queries.append([int(x) for x in input().split()])

    solve(queries, H, W, D)


if __name__ == '__main__':
    main(sys.argv[1:])
### BUGGY CODE ###

from collections import Counter

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

kosu = [0] * N

for i in range(N):
    kosu = Counter(A)

tempSum = 0
for i in range(N):
    tempSum += kosu[i+1] * (kosu[i+1] - 1) // 2


def C(N):
    if N <= 0:
        return 0
    else:
        return N*(N-1)//2


for i in range(N):
    print(tempSum - C(kosu[A[i]]) + C(kosu[A[i]] - 1))




### FIXED CODE ###

from collections import Counter
n = int(input())
A = list(map(int, input().split()))

cnt = Counter(A)

ans = 0
for v in cnt.values():
    ans += v * (v - 1) // 2

for k in A:
    # n*(n-1)//2 - (n-1)*(n-2)//2 = n - 1
    print(ans - (cnt[k] - 1))
### BUGGY CODE ###

import sys
from collections import deque


def main():
    n, m = map(int, sys.stdin.readline().split())

    to = [[] for _ in range(n + 1)]
    a_set = {x for x in range(1, n + 1)}
    b_set = set()
    for _ in range(n - 1 + m):
        a, b = map(int, sys.stdin.readline().split())
        to[a].append(b)
        b_set.add(b)
    root = (a_set - b_set).pop()
    dist = [0] * (n + 1)
    pre = [0] * (n + 1)
    que = deque([])
    que.append(root)

    while que:
        p = que.popleft()
        for i in to[p]:
            if dist[i] < dist[p] + 1:
                dist[i] = dist[p] + 1
                pre[i] = p
                que.append(i)

    for i in range(1, n + 1):
        print(pre[i])


if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
from collections import deque


def main():
    n, m = map(int, sys.stdin.readline().split())

    out_list = [[] for _ in range(n + 1)]
    in_cnt = [0] * (n + 1)
    in_cnt[0] = -1
    for _ in range(n - 1 + m):
        a, b = map(int, sys.stdin.readline().split())
        out_list[a].append(b)
        in_cnt[b] = in_cnt[b] + 1
    root = in_cnt.index(0)
    ans = [0] * (n + 1)
    que = deque([])
    que.append(root)

    while que:
        p = que.popleft()
        for i in out_list[p]:
            in_cnt[i] = in_cnt[i] - 1
            if in_cnt[i] == 0:
                que.append(i)
                ans[i] = p

    for i in ans[1:]:
        print(i)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

import numpy as np
n=int(input())
a=list(map(int,input().split()))
a1=[]
a2=[]
for i in range(n):
  if i+1-a[i]>0:
    a1.append(i+1-a[i])
for i in range(n):
  a2.append(i+1+a[i])
count=0
for k in a1:
  for l in a2:
    if k==l:
      count+=1
print(count)

### FIXED CODE ###

from collections import Counter
n=int(input())
alist=list(map(int,input().split()))
a1=[]
a2=[]
for i,a in enumerate(alist):
  a2.append(i-a)
  a1.append(i+a)
aa=Counter(a2)
count=0
for k in a1:
  count+=aa.get(k,0)
print(count)