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

import collections
import math
import copy
N = int(input())
A = list(map(int,input().split()))

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(N):
    L = A.copy()
    del L[i]
    c = collections.Counter(L)
    l = [i for i in c.values() if i != 1]
    ans = 0
    for j in l:
        ans += combinations_count(j,2)
    print(ans)

### FIXED CODE ###

import numpy as np
N = int(input())
A = np.array(input().split(),np.int64)

bincnt = np.bincount(A)

total = (bincnt * (bincnt - 1)).sum() // 2
ans = (total - (bincnt-1))[A].astype(str)

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

import math
N = int(input())
cnt = 0
for a in range(1,N):
  for b in range(1,math.ceil(N/a)):
    c = N - a * b
    if c <= 0:
      break
    else:
      # print("a,b :",end='')
      # print(a,b)
      # print("c :" + str(c))
      cnt += 1
print(cnt)


### FIXED CODE ###

import math
N = int(input())
cnt = 0
for a in range(1,N):
  for b in range(a,math.ceil(N/a)):
    c = N - a * b
    if c <= 0:
      break
    else:
      if a == b:
        cnt += 1
      else :
        cnt += 2
print(cnt)
### BUGGY CODE ###

n,q=map(int,input().split())
stx=[list(map(int,input().split())) for _ in range(n)]
d=[int(input()) for _ in range(q)]
inf=float('inf')

import heapq
class pqheap:
  def __init__(self,key=None):
    self.p = list()
    self.q = list()

  def insert(self,x):
    heapq.heappush(self.p, x)
    return

  def erase(self,x):
    heapq.heappush(self.q, x)
    return

  def minimum(self):
    while self.q and self.p[0] == self.q[0]:
      heapq.heappop(self.p)
      heapq.heappop(self.q)
    return self.p[0] if len(self.p)>0 else -1
memopush={}
memopop={}
from bisect import bisect_left,bisect_right
for s,t,x in stx:
  l,r=max(0,s-x),max(0,t-x)
  # 出発時刻が[l,r)の人の進む距離がxで抑えられる
  if l in memopush:
    memopush[l].append(x)
  else:
    memopush[l]=[x]
  if r in memopop:
    memopop[r].append(x)
  else:
    memopop[r]=[x]
keys=list(set(memopush.keys()).union(set(memopop.keys())))
keys.sort()
ans=[-1]*q
pq=pqheap()
dct=[[-1,-1]]
for k in keys:
  if k in memopush:
    for v in memopush[k]:
      pq.insert(v)
  if k in memopop:
    for v in memopop[k]:
      pq.erase(v)
  dct.append([k,pq.minimum()])
i=0
for x in d:
  while i+1<len(dct) and dct[i+1][0]<=x:
    i+=1
  if i>=len(dct):
    print(-1)
  else:
    print(dct[i][1])

#print(dct)

### FIXED CODE ###

n,q=map(int,input().split())
stx=[list(map(int,input().split())) for _ in range(n)]
d=[int(input()) for _ in range(q)]
inf=float('inf')

import heapq
class pqheap:
  def __init__(self,key=None):
    self.p = list()
    self.q = list()

  def insert(self,x):
    heapq.heappush(self.p, x)
    return

  def erase(self,x):
    heapq.heappush(self.q, x)
    return

  def minimum(self):
    while self.q and self.p[0] == self.q[0]:
      heapq.heappop(self.p)
      heapq.heappop(self.q)
    return self.p[0] if len(self.p)>0 else -1
memopush={}
memopop={}
from bisect import bisect_left,bisect_right
for s,t,x in stx:
  l,r=max(0,s-x),max(0,t-x)
  # 出発時刻が[l,r)の人の進む距離がxで抑えられる
  if l in memopush:
    memopush[l].append(x)
  else:
    memopush[l]=[x]
  if r in memopop:
    memopop[r].append(x)
  else:
    memopop[r]=[x]
keys=list(set(memopush.keys()).union(set(memopop.keys())))
keys.sort()
pq=pqheap()
dct=[[-1,-1]]
for k in keys:
  if k in memopush:
    for v in memopush[k]:
      pq.insert(v)
  if k in memopop:
    for v in memopop[k]:
      pq.erase(v)
  dct.append([k,pq.minimum()])
i=0
for x in d:
  while i+1<len(dct) and dct[i+1][0]<=x:
    i+=1
  if i>=len(dct):
    print(-1)
  else:
    print(dct[i][1])

#print(dct)
### BUGGY CODE ###

n=int(input())
tmp = 1
dat = list(map(int, input().split(" ")))
for d in dat:
    tmp *= d

if tmp > 1000000000000000000:
    print ("-1")
else:
    print (tmp)

### FIXED CODE ###

n=int(input())
tmp = 1
dat = list(map(int, input().split(" ")))
#print(dat, (0 in dat))
over = False
if 0 in dat:
    print ("0")
else:
    for d in dat:
        tmp *= d
        if tmp > 1000000000000000000:
            print ("-1")
            over = True
            break
    if not over:
        print (tmp)
### BUGGY CODE ###

def solve():
    from bisect import bisect_left

    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    M = max(A) + max(B)
    K = len(bin(M)) - 2
    mask = (1 << K) - 1
    k = K - 1
    T = 1 << k
    ans = 0
    while k >= 0:
        for i in range(N):
            B[i] &= mask
        B.sort()
        bit = 0
        for a in A:
            a_ = a & mask
            T1 = bisect_left(B, T - a_)
            T2 = bisect_left(B, 2 * T - a_, T1)
            T3 = bisect_left(B, 3 * T - a_, T2)
            T4 = bisect_left(B, 4 * T - a_, T3)
            bit += (T4 - T3) + (T2 - T1)
            bit &= 1
        ans += bit * T
        k -= 1
        T >>= 1
        mask >>= 1

    print(ans)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

def solve():
    # from bisect import bisect_left
    import sys

    N = int(input())
    A = [int(x) for x in sys.stdin.readline().split()]
    B = [int(x) for x in sys.stdin.readline().split()]
    M = max(A) + max(B)
    K = len(bin(M)) - 2
    mask = (1 << K) - 1
    k = K - 1
    T = 1 << k
    ans = 0
    while k >= 0:
        for i in range(N):
            B[i] &= mask
            A[i] &= mask
        B = list(sorted(b & mask for b in B))
        A = list(sorted(a & mask for a in A))
        bit = 0
        T1, T2, T3 = 0, 0, 0
        for a in reversed(A):
            while T1 < N and a + B[T1] < T:
                T1 += 1
            while T2 < N and a + B[T2] < 2 * T:
                T2 += 1
            while T3 < N and a + B[T3] < 3 * T:
                T3 += 1
            # T1 = bisect_left(B, T - a, T1)
            # T2 = bisect_left(B, 2 * T - a, T2)
            # T3 = bisect_left(B, 3 * T - a, T3)
            # T4 = bisect_left(B, 4 * T - a, T4)
            bit += (N - T3) + (T2 - T1)
            bit &= 1
        ans += bit * T
        k -= 1
        T >>= 1
        mask >>= 1

    print(ans)


if __name__ == '__main__':
    solve()
### BUGGY CODE ###

from itertools import permutations

N,M,R = map(int,input().split())
rseq = list(map(int,input().split()))
graph = [[-1]*N for x in range(N)]

for i in range(M):
    A,B,C = map(int,input().split())
    A,B = A-1,B-1
    graph[A][B] = graph[B][A] = C

#FloydWarshall
for k in range(N):
    for i in range(N):
        for j in range(N):
            if graph[i][k] == -1 or graph[k][j] == -1:
                continue
            if graph[i][j] == -1 or graph[i][j] > graph[i][k] + graph[k][j]:
                graph[i][j] = graph[i][k] + graph[k][j]

minimum = 200000000
for p in permutations(rseq):
    total = 0
    for i in range(1,R):
        total += graph[p[i]-1][p[i-1]-1]
        if total > minimum:
            break
    if total < minimum:
        minimum = total
print(minimum)


### FIXED CODE ###

from itertools import permutations
 
 
def warshallFloyd(V, dp):
    for k in range(V):
        for i in range(V):
            for j in range(V):
                # dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])
                new_dist = dp[i][k] + dp[k][j]
                if dp[i][j] > new_dist:
                    dp[i][j] = new_dist
 
 
def main():
    N, M, R = [int(x) for x in input().split()]
    destinations = [int(x) for x in input().split()]
    dp = [[float('inf')]*(N+1) for _ in range(N+1)]
    for i in range(N+1):
        dp[i][i] = 0
    for _ in range(M):
        f, t, d = [int(x) for x in input().split()]
        dp[f][t] = dp[t][f] = d
 
    warshallFloyd(N+1, dp)
 
    minimum_cost = float('inf')
    for route in permutations(destinations, len(destinations)):
        cost = 0
        while len(route) > 1:
            f, t = route[0], route[1]
            cost += dp[f][t]
            if cost > minimum_cost:
                break
            route = route[1:]
        if cost < minimum_cost:
            minimum_cost = cost
    print(minimum_cost)
 
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

n = int(input())
a = [int(input()) for i in range(n)]

now_col = []

for i in range(n):
    now_k = -1
    now_v = -1
    for k, v in enumerate(now_col):
        if now_v < v < a[i]:
            now_v = v
            now_k = k
    if now_k != -1:
        now_col[now_k] = a[i]
    else:
        now_col.append(a[i])

print(len(now_col))

### FIXED CODE ###

import bisect

n = int(input())
a = [int(input()) for _ in range(n)]
dp = [-1 for _ in range(n)]
for i in a:
    dp[bisect.bisect_left(dp, i) - 1] = i

print(sum([i >= 0 for i in dp]))
### BUGGY CODE ###

from sys import stdin
import numpy as np
def main():
    #入力
    readline=stdin.readline
    mod=10**9+7
    s=readline().strip()
    n=len(s)

    dp=np.zeros((n,13),dtype=np.int64)
    tmp1=np.array(range(10),dtype=np.int64)%13
    keta=10
    for i in range(n-1,-1,-1):
        if i==n-1:
            if s[i]=="?":
                dp[i,0:10]=1
            else:
                dp[i][int(s[i])]=1
        else:
            if s[i]=="?":
                tmp2=(keta*tmp1)%13
            else:
                tmp2=(keta*int(s[i]))%13
            for j in range(13):
                dp[i,(tmp2+j)%13]+=dp[i+1,j]
            dp[i]%=mod
            keta*=10
            keta%=13

    print(dp[0][5])

if __name__=="__main__":
    main()

### FIXED CODE ###

#import numpy as np
def main():
    S=input()
    #dp=np.zeros((len(S)+1,13),dtype=int)
    dp=[[0]*13 for _ in range(len(S)+1)]
    dp[0][0]=1
    mod=10**9+7
    """
    for i in range(1,len(S)+1):
        for a in range(13):
            if S[i-1]=="?":
                if a*10%13<(a*10+10)%13:
                    dp[i][a*10%13:(a*10+10)%13]+=dp[i-1][a]
                    dp[i][a*10%13:(a*10+10)%13]%=mod
                else:
                    dp[i][a*10%13:]+=dp[i-1][a]
                    dp[i][a*10%13:]%=mod
                    dp[i][:(a*10+10)%13]+=dp[i-1][a]
                    dp[i][:(a*10+10)%13]%=mod
            else:
                dp[i][(a*10+int(S[i-1]))%13]+=dp[i-1][a]
                dp[i][(a*10+int(S[i-1]))%13]%=mod
    print(dp[len(S)][5])
"""
    for i in range(1,len(S)+1):
        for a in range(13):
            if S[i-1]=="?":
                for n in range(10):
                    dp[i][(a*10+n)%13]+=dp[i-1][a]
                    dp[i][(a*10+n)%13]%=mod
            else:
                dp[i][(a*10+int(S[i-1]))%13]+=dp[i-1][a]
                dp[i][(a*10+int(S[i-1]))%13]%=mod
    print(dp[len(S)][5])
if __name__=="__main__":
    main()
### BUGGY CODE ###

a = int(input())
List = [(input()) for i in range(a)]

x=[]

for i in List:
    if not (i in x):
        x.append(i)

    
print(len(x))

### FIXED CODE ###

a = int(input())
List = [(input()) for i in range(a)]


import collections

c = collections.Counter(List)

print(len(c))
### BUGGY CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))

arr = []
tmp = 0

for n in P:
  arr.append((n+1)/2)

for i in range(0, N - K + 1):
  max_value = 0
  max_value = sum(arr[i:i+K])
  if max_value >= tmp: 
    tmp = max_value

print("{:.12f}".format(tmp))

### FIXED CODE ###

import queue

N, K = map(int, input().split())
P = list(map(int, input().split()))

q = queue.Queue()

#arr = [(n+1)/2 for n in P]
mx = 0
s = 0

for i in range(N):
  s += P[i]+1
  q.put(P[i]+1)
  if q.qsize() > K:
    s -= q.get()
  if q.qsize() == K:
    mx = max(mx, s)

ans = mx/2
print(ans)
### BUGGY CODE ###

N,Q = map(int,input().split())
Edge = [[] for _ in range(N+1)]

for _ in range(N-1):
    a,b, = map(int,input().split())
    Edge[a].append(b)
    Edge[b].append(a)

PX = [list(map(int,input().split())) for _ in range(Q)]

visited = [True for _ in range(N+1)]
visited[1] = False
queue = [1]
Ans = [0]*(N+1)

for p,x in PX:
    Ans[p] += x

while len(queue) > 0:
    nextnode = queue.pop(0)
    for e in Edge[nextnode]:
        if visited[e]:
            visited[e] = False
            queue.append(e)
            Ans[e] += Ans[nextnode]
print(*Ans[1:],sep = " ")



### FIXED CODE ###

N,Q = map(int,input().split())
Edge = [[] for _ in range(N+1)]

for _ in range(N-1):
    a,b, = map(int,input().split())
    Edge[a].append(b)
    Edge[b].append(a)

PX = [list(map(int,input().split())) for _ in range(Q)]

visited = [True for _ in range(N+1)]
visited[1] = False
stack = [1]
Ans = [0]*(N+1)

for p,x in PX:
    Ans[p] += x

while len(stack) > 0:
    nextnode = stack.pop()
    for e in Edge[nextnode]:
        if visited[e]:
            visited[e] = False
            stack.append(e)
            Ans[e] += Ans[nextnode]
print(*Ans[1:],sep = " ")
### BUGGY CODE ###

# python には結構厳しいTLE・・・python以外のお勉強時間ないよ～( ;∀;)
# . から見た # の最大距離の方が楽ではあるが・・・
# 嫌いだけど def main も使ってみた．

def main():
  H, W = list(map(int, input().split()))
  all_count = H * W
  L = [True if j == "#" else False for i in range(H) for j in input()]
  all_count = H * W
  blacks = [i for i in range(all_count) if L[i]]
  black_count = len(blacks)
 
  cands_H = [-W, W]
  cands_W = [-1, 1]
  result = 0
  while black_count < all_count:
    next_steps = set([black+cand for black in blacks for cand in cands_H]) | set([black+cand for black in blacks for cand in cands_W if black%W not in [0, W-1]])
    blacks = [i for i in next_steps if i >= 0 and i < all_count and not L[i]]
    for i in blacks:
      L[i] = True
    black_count += len(blacks)
    result += 1

  print(result)

if __name__ == "__main__":
  main()


### FIXED CODE ###

# python には結構厳しいTLE・・・python以外のお勉強時間ないよ～( ;∀;)
# . から見た # の最大距離の方が楽ではあるが・・・
# 嫌いだけど def main も使ってみた．
from collections import deque
import copy

def main():
  H, W = list(map(int, input().split()))
  L = [[j=="#" for j in input()] for i in range(H)]
  q = deque([(i, j) for i in range(H) for j in range(W) if L[i][j]])
  cands = [(0, -1), (0, 1), (-1, 0), (1, 0)]
  result = 0
  while True:
    nq = deque()
    while q:
      i, j = q.popleft()
      if i > 0 and not L[i-1][j]:
        L[i-1][j] = True
        nq.append((i-1, j))
      if j > 0 and not L[i][j-1]:
        L[i][j-1] = True
        nq.append((i, j-1))
      if i < H-1 and not L[i+1][j]:
        L[i+1][j] = True
        nq.append((i+1, j))
      if j < W-1 and not L[i][j+1]:
        L[i][j+1] = True
        nq.append((i, j+1))
    if nq:
      q = copy.copy(nq)
    else:
      break    
    result += 1
  print(result)

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

h,w,d=(int(i) for i in input().split())
num=[None for i in range(h*w)]
for i in range(h):
    a=list(map(int,input().split()))
    for j in range(w):
        num[a[j]-1]=(i,j)
q=int(input())
for i in range(q):
    l,r=list(map(int,input().split()))
    result=0
    while l!=r:
        result+=abs(num[l+d-1][0]-num[l-1][0])+abs(num[l+d-1][1]-num[l-1][1])
        l+=d
    print(result)

### FIXED CODE ###

h,w,d=(int(i) for i in input().split())
num=[None for i in range(h*w)]
for i in range(h):
    a=list(map(int,input().split()))
    for j in range(w):
        num[a[j]-1]=(i,j)
numm=[None for i in range(h*w)]
for i in range(d):
    numm[i]=0
for i in range(d,h*w):
    numm[i]=numm[i-d]+abs(num[i][0]-num[i-d][0])+abs(num[i][1]-num[i-d][1])

q=int(input())
for i in range(q):
    l,r=list(map(int,input().split()))
    print(numm[r-1]-numm[l-1])
### BUGGY CODE ###

N, M = map(int, input().split())
E = [set() for i in range(N)]
for i in range(M):
  s, t = map(int, input().split())
  s, t = s-1, t-1
  E[s].add(t)
Vs = [1000000.0]*N
Vs[-1] = 0
for i in reversed(range(N-1)):
  js = E[i]
  v = 0
  for j in js:
    v += Vs[j]
  v = 1+v/len(js)
  Vs[i] = v
r = Vs[0]
rs = [r]
Vs0 = Vs
for n in range(N-1):
  Vs = [1000000.0]*N
  for i in range(n+1, N):
    Vs[i] = Vs0[i]
  for i in reversed(range(n+1)):
    js = E[i]
    if i == n:
      jmin = max(js, key=lambda j: Vs[j])
      js = js-{jmin}
    if len(js) == 0:
      break
    #p = 1/len(js)
    v = 0
    for j in js:
      v += Vs[j]
    v = 1+v/len(js)
    Vs[i] = v
  r = Vs[0]
  rs.append(r)
#print(rs)
r = min(rs)
print(r)


### FIXED CODE ###

N, M = map(int, input().split())
E = [set() for i in range(N)]
for i in range(M):
  s, t = map(int, input().split())
  s, t = s-1, t-1
  E[s].add(t)
Vs = [1000000.0]*N
Vs[-1] = 0
for i in reversed(range(N-1)):
  js = E[i]
  v = 0
  for j in js:
    v += Vs[j]
  v = 1+v/len(js)
  Vs[i] = v
r = Vs[0]
rs = [r]
Vs0 = Vs
for n in range(N-1):
  Vs = [1000000.0]*N
  for i in range(n+1, N):
    Vs[i] = Vs0[i]
  for i in reversed(range(n+1)):
    js = E[i]
    if i == n:
      jmin = max(js, key=lambda j: Vs[j])
      js = js-{jmin}
    if len(js) == 0:
      break
    #p = 1/len(js)
    v = 0
    for j in js:
      v += Vs[j]
    v = 1+v/len(js)
    Vs[i] = v
  r = Vs[0]
  rs.append(r)
#print(rs)
r = min(rs)
print(r)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
bi = [n for _ in range(n)]
for i in range(n):
    for j in range(n):
        if b[i] <= a[j]:
            bi[i] = j
            break
ans = 0
for i in range(n):
    for j in range(n):
        if c[i] <= b[j]:
            break
        else:
            ans += bi[j]
print(ans)

### FIXED CODE ###

import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0;
for bj in b:
    ai = bisect.bisect_left(a, bj);
    ck = n - bisect.bisect_right(c, bj);
    ans += ai * ck;
print(ans)
### BUGGY CODE ###

from collections import deque

n, m = map(int, input().split(" "))
load = {}
for _ in range(m):
    a, b = map(int, input().split(" "))
    load[a] = load.get(a, []) + [b]
    load[b] = load.get(b, []) + [a]

queue = deque([1])
visited = [-1] * (n+1)
visited[1] = 1

while len(queue) != 0:
    curr = queue.popleft()
    for _next in load[curr]:
        if visited[_next] == -1:
            visited[_next] = curr
            queue.append(_next)

if not all(map(lambda x: x == -1, visited)):
    print("Yes")
    for i in visited[2:]:
        print(i)
else:
    print("No")

### FIXED CODE ###

from collections import deque
n, m = map(int, input().split(" "))
load = {i:[] for i in range(1, n+1)}
for _ in range(m):
    a, b = map(int, input().split(" "))
    load[a].append(b)
    load[b].append(a)

queue = deque([1])
visited = {1: 1}

while len(queue) != 0:
    curr = queue.popleft()
    for _next in load[curr]:
        if visited.get(_next, -1) == -1:
            visited[_next] = curr
            queue.append(_next)

if len(visited) == n:
    print("Yes")
    for i in range(2, n+1):
        print(visited[i])
else:
    print("No")
### BUGGY CODE ###

n = int(input())
A = []
for i in range(n):
    A.append(int(input()))

for i in range(n):
    print(max(A[:i]+A[i+1:]))


### FIXED CODE ###

import copy
n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
B = copy.copy(A)
B.sort()
A_max = B[-1]
A_max2 = B[-2]

for i in range(n):
    if A[i] < A_max:
        print(A_max)
    elif A[i] == A_max:
        print(A_max2)
### BUGGY CODE ###

def calc_f(a,b):
    if type(a) == str:
        a_bin = a
    else:
        a_bin = bin(a)[2:]
    if type(b) == str:
        b_bin = b
    else:
        b_bin = bin(b)[2:]
    
    if len(a_bin) > len(b_bin):
        b_bin = '0' * (len(a_bin) - len(b_bin)) + b_bin

    if len(b_bin) > len(a_bin):
        a_bin = '0' * (len(b_bin) - len(a_bin)) + a_bin

    s = ''
    for k in range(len(a_bin)):
        if a_bin[k] == b_bin[k]:
            s = s + '0'
        else:
            s = s + '1'
#     print(a_bin, b_bin, s)
    return s

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

c = bin(a)[2:]

for k in range(1, b - a + 1):
    c = calc_f(c, a + k)

ans = int(c, 2)
print(ans)

### FIXED CODE ###

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

c = []
if a%2 == 0:
    if b%2 == 0:
        # e e 
        c = [int(((b - 1 - a + 1)/2)%2), b]
    else:
        # e o
        c = [int(((b - a + 1)/2)%2)]
else:
    if b%2 == 0:
        # o e
        c = [a, (int((b - a)/2)%2), b]
    else:
        # o o
        c = [a, int(((b + 1 - a)/2)%2)]

d = 0
for cc in c:
#     print(c)
    d += int(bin(cc)[2:])
    d = str(d)
    d = d.replace('2', '0')
    d = int(d)
    
print(int(str(d), 2))
### BUGGY CODE ###

R, G, B, N = map(int, input().split())

ans = 0
for r in range(N//R + 1):
    for g in range(N//G + 1):
        for b in range(N//B + 1):
            if r*R + g*G + b*B == N:
                ans += 1 
print(ans)

### FIXED CODE ###

R, G, B, N = map(int, input().split())

ans = 0
for r in range(N//R + 1):
    for g in range((N - r*R)//G + 1):
        if (N - r*R - g*G)%B == 0:
                ans += 1
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()

b = [True for i in range(n)]

for i, j in enumerate(a):
    if i < n-1 and b[i]:
        for k in range(i+1, n):
            if b[k] and a[k] % j == 0:
                b[k] = False
        if a[i] == a[i+1]:
            b[i] = False

print(b.count(True))


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()

b = [True for i in range(a[-1]+1)]

ans = 0

for i, j in enumerate(a):
    if b[j]:
        t = 1
        while j*t < len(b):
            b[j*t] = False
            t += 1
        
        if i == n-1:
            ans += 1
        elif j != a[i+1]:
            ans += 1
        
print(ans)
### BUGGY CODE ###

import numpy as np
n,m,q = map(int,raw_input().split())

imos = [[0 for i in xrange(n)] for j in xrange(n)]

for i in xrange(m):
	f,t = map(int,raw_input().split())
	f -= 1
	t -= 1
	for j in range(f+1):
		imos[j][t] += 1

#for i in range(n):
#	for j in range(1,n):
#		imos[i][j] = imos[i][j-1] + imos[i][j]

for i in xrange(n):
	imos[i] = np.cumsum(imos[i])

for i in xrange(q):
	a,b = map(int,raw_input().split())
	print imos[a-1][b-1]


### FIXED CODE ###

import numpy as np
n,m,q = map(int,raw_input().split())

imos = [[0 for i in xrange(n)] for j in xrange(n)]

for i in xrange(m):
	f,t = map(int,raw_input().split())
	f -= 1
	t -= 1
	imos[f][t] += 1

for i in range(n-1,0,-1):
	for j in range(n):
		imos[i-1][j] = imos[i][j] + imos[i-1][j]

for i in xrange(n):
	imos[i] = np.cumsum(imos[i])

for i in xrange(q):
	a,b = map(int,raw_input().split())
	print imos[a-1][b-1]
### BUGGY CODE ###

from functools import reduce
from operator import mul
import math
import copy
 
def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under
  
n = int(input())
l = list(map(int, input().split()))
d = {}
s_sum = {}
s_ans = {}
s = list(set(l))
m = 0
for i in range(len(s)):
    d[s[i]] = l.count(s[i])
for k, v in d.items():
    if v > 1:
        a = cmb(v, 2)
        s_ans[k] = a
        m += a
    else:
        s_ans[k] = 0
for i in range(len(l)):
    if not l[i] in d:
        print(m)
    elif l[i] in s_sum:
        print(s_sum[l[i]])
    else:
        e = copy.deepcopy(d)
        e[l[i]] -= 1
        ans = m - s_ans[l[i]]
        if e[l[i]] > 1:
            ans += cmb(e[l[i]], 2)
        s_sum[l[i]] = ans
        print(ans)

### FIXED CODE ###

import collections

def count_defaultdict(it):
    counter = collections.defaultdict(int)
    for x in it:
        counter[x] += 1
    return dict(counter)

_ = int(input())
l = list(map(int, input().split()))
all_sum = 0
count = count_defaultdict(l)
for _, v in count.items():
    all_sum += v * (v - 1) // 2
for i in range(len(l)):
    if count[l[i]] > 1:
        v = count[l[i]]
        print(all_sum - v * (v-1) // 2 + (v-1) * (v-2)//2)
    else:
        print(all_sum)