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

import sys
input = lambda: sys.stdin.readline().rstrip('\r\n')

N, Q = map(int, input().split())
C = list(map(int, input().split()))

B = max(1, int(N**.5))

Qs = []
for i in range(Q):
	l, r = map(lambda s: int(s)-1, input().split())
	Qs.append((l, r+1, i))

Qs.sort(key=lambda v: (v[0]//B, v[1]))

cnt = [0] * (N+1)
diff = 0

ans = [-1] * Q

left, right = 0, 0

def add(i):
	global cnt, diff
	x = C[i]
	cnt[x] += 1
	if cnt[x] == 1:
		diff += 1

def remove(i):
	global cnt, diff
	x = C[i]
	cnt[x] -= 1
	if cnt[x] == 0:
		diff -= 1

for l, r, i in Qs:
	while right < r:
		add(right)
		right += 1

	while r < right:
		right -= 1
		remove(right)

	while left < l:
		remove(left)
		left += 1

	while l < left:
		left -= 1
		add(left)

	ans[i] = diff

print('\n'.join(map(str, ans)))


### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip('\r\n')

N, Q = map(int, input().split())
C = list(map(int, input().split()))

by_R = [[] for _ in range(N+1)]
for i in range(Q):
	l, r = map(lambda s: int(s)-1, input().split())
	by_R[r+1].append((l, i))

s = [0] * N
def update(pos, dif):
	while pos < N:
		s[pos] += dif
		pos |= pos + 1

def query(pos):
	res = 0
	while pos > 0:
		res += s[pos-1]
		pos &= pos - 1
	return res

diff = 0
ans = [-1] * Q
last = [-1] * (N+1)

for i, v in enumerate(C):
	if last[v] != -1:
		update(last[v], -1)
	else:
		diff += 1

	update(i, 1)
	last[v] = i

	for l, j in by_R[i+1]:
		ans[j] = diff - query(l)

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

k,s = map(int,input().split())
count = 0
if 3*k==s:
  print(1)
else:
  for x in range(k+1):
    if x+2*k<s:continue
    for y in range(k+1):
      if x+y+k<s:continue
      for z in range(k+1):
        if x+y+z==s:
          count += 1
  print(count)

### FIXED CODE ###

k,s=map(int,input().split())
print(len([1 for z in range(k+1) for y in range(k+1) if 0<=s-y-z<=k]))
### BUGGY CODE ###

import math
from collections import Counter

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

def combinations_count(n, r):
    if n==1:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for k in range(N):
    array_k = [Balls[i] for i in range(N) if i!=k]
    sum_k=0
    c= Counter(array_k)
    for j in list(c.values()):
        sum_k += combinations_count(j,2)
    
    print(sum_k)




### FIXED CODE ###

import math
from collections import Counter

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

def combinations_count(n, r):
    if n==1:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
c = Counter(Balls)
d={}
ALL_SUM=0
for i,j in c.most_common():
    d[i]=j
    ALL_SUM+=combinations_count(j,2)
for k in Balls:
    print(ALL_SUM-(d[k] - 1))

# for k in range(N):
#     tmp=Balls[k]
#     array_k = Balls
#     sum_k=0
#     c= Counter(array_k)


#     for j in list(c.values()):
#         sum_k += combinations_count(j,2)
    
#     Balls.insert(k,tmp)
#     print(sum_k)
### BUGGY CODE ###

N, P = map(int, input().split())
S = input()

l = len(S)
if P == 2:
    ans = 0
    for i in range(l):
        if int(S[i])%2 == 0:
            ans += i+1
elif P == 5:
    ans = 0
    for i in range(l):
        if int(S[i])%5 == 0:
            ans += i+1
else:
    data = [0]*P
    temp = 0
    for i in range(l-1, -1, -1):
        temp += (int(S[i])*(10**(l-i-1)))%P
        temp %= P
        data[temp] += 1
    ans = data[0]
    for item in data:
        if item > 1:
            ans += item*(item-1)//2

print(ans)

### FIXED CODE ###

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

l = len(S)
if P == 2:
    ans = 0
    for i in range(l):
        if S[i]%2 == 0:
            ans += i+1
elif P == 5:
    ans = 0
    for i in range(l):
        if S[i]%5 == 0:
            ans += i+1
else:
    data = [0]*P
    temp = 0
    ans = 0
    for i in range(l-1, -1, -1):
        temp += S[i]*pow(10, l-i-1, P)
        temp %= P
        ans += data[temp]
        data[temp] += 1
    ans += data[0]

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

# TLE
import sys
import numpy as np

# input = sys.stdin.readline

s = list(input())

n = int(input())

reverse = False
for ii in range(n):
    q = input()
#     print("".join(s))
    if q[0] == "1":
        reverse += 1
        reverse %= 2
#         s = s[::-1]
    else:
        t, f, c = q.split()
        if f == "1":
            if reverse:
                s.append(c)
            else:
                s.insert(0, c)
        else:
            if reverse:
                s.insert(0, c)
            else:
                s.append(c)
if reverse:
    s = s[::-1]
print("".join(s))

### FIXED CODE ###

# TLE
import sys
import numpy as np
from collections import deque

# input = sys.stdin.readline

s = list(input())

n = int(input())

d = deque(s)

reverse = False
for ii in range(n):
    q = input()
#     print("".join(s))
    if q[0] == "1":
        reverse += 1
        reverse %= 2
#         s = s[::-1]
    else:
        t, f, c = q.split()
        if f == "1":
            if reverse:
                d.append(c)
            else:
                d.appendleft(c)
        else:
            if reverse:
                d.appendleft(c)
            else:
                d.append(c)
                
if reverse:
    d.reverse()
print("".join(d))
### BUGGY CODE ###

# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

#n = int(input())
n,q = [int(i) for i in readline().split()]

g = [[] for _ in range(n)]
for i in range(n-1):
    a,b = [int(i) for i in readline().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)

add = [0]*n
for _ in range(q):
    p,x = [int(i) for i in readline().split()]
    add[p-1] += x

ans = [0]*n
#ans[0] = add[0]

def dfs(v,p,value): #p: parent of v
    value += add[v]
    ans[v] = value
    for c in g[v]:
        if c == p: continue
        dfs(c,v,value)

dfs(0,-1,0)

#print(add)

print(*ans)


### FIXED CODE ###

# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

#n = int(input())
n,q = [int(i) for i in readline().split()]

g = [[] for _ in range(n)]
for i in range(n-1):
    a,b = [int(i) for i in readline().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)

add = [0]*n
for _ in range(q):
    p,x = [int(i) for i in readline().split()]
    add[p-1] += x

ans = [0]*n
#ans[0] = add[0]

def dfs(v,p,value): #p: parent of v
    value += add[v]
    ans[v] = value
    for c in g[v]:
        if c == p: continue
        dfs(c,v,value)

dfs(0,-1,0)

#print(add)

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

N = int(input())
A = [int(x) for x in input().split()]

S=0
ans =-1

if 1 in A:    
    for i in range(1,N+1):
        if i in A[S::]:
            S=A.index(i,S)
            ans =N-i
        else:
            break

print(ans)

### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]

S=0
ans =-1
x=1

if 1 in A:
    ans = 0
    for i in A:
        if i ==x :
            x += 1
    ans = N - x +1
            
print(ans)
### BUGGY CODE ###

from collections import Counter
import sys

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


def f(c1, c2, c3):
    if dp[c1][c2][c3] is not None:
        return dp[c1][c2][c3]

    res = (n \
           + (f(c1 - 1, c2, c3) * c1 if c1 else 0) \
           + (f(c1 + 1, c2 - 1, c3) * c2 if c2 else 0) \
           + (f(c1, c2 + 1, c3 - 1) * c3 if c3 else 0)) \
          / (c1 + c2 + c3)
    dp[c1][c2][c3] = res
    return res


n = int(input())
a = tuple(map(int, input().split()))

c = Counter(a)
c1 = c[1]
c2 = c[2]
c3 = c[3]

dp = tuple(
    tuple(
        [None] * (c3 + 1) for _ in range(c2 + c3 + 1)
    ) for _ in range(c1 + c2 + c3 + 1))
dp[0][0][0] = 0
# dp[x][y][z]:=1,2,3個の皿がx,y,z残っているときの期待値

print(f(c1, c2, c3))

# dp[now] =
# 1
# + dp[1個の皿を食べた] * p
# + dp[2個の皿を食べた] * p
# + dp[3個の皿を食べた] * p
# + dp[0個の皿を食べた==now] * p


### FIXED CODE ###

def main():
    from collections import Counter

    n = int(input())
    a = tuple(int(x) for x in input().split())

    c = Counter(a)
    c1 = c[1]
    c2 = c[2]
    c3 = c[3]

    x1 = 310 ** 2
    x2 = 310

    dp = [0.0] * (310 ** 3)
    dp[0] = 0.0
    # dp[x * x1 + y * x2 + z]:=1,2,3個の皿がx,y,z残っているときの期待値

    for r3 in range(c3 + 1):
        d3 = c3 - r3
        for r2 in range(c2 + d3 + 1):
            for r1 in range(c1 + d3 + c2 - r2 + 1):
                ind = r1 * x1 + r2 * x2 + r3
                if ind != 0:
                    dp[ind] = (n \
                               + (dp[ind - x1] * r1 if r1 > 0 else 0) \
                               + (dp[ind + x1 - x2] * r2 if r2 > 0 else 0) \
                               + (dp[ind + x2 - 1] * r3 if r3 > 0 else 0)) \
                              / (r1 + r2 + r3)

    print(dp[c1 * x1 + c2 * x2 + c3])


if __name__ == '__main__':
    main()

# dp[now] =
# 1
# + dp[1個の皿を食べた] * p
# + dp[2個の皿を食べた] * p
# + dp[3個の皿を食べた] * p
# + dp[0個の皿を食べた==now] * p

# if mainの追加
# 初期値None->-1.0にした
# checked配列を辞めた
# チェック済みかどうかの判定を-1.0と一致するかの比較にした

# カウントはCounterを使う方が速い
# 1次元にした
# resの加算を複数回に分けると
# 三項演算子より遅くなる
# 再帰関数を辞めた
### BUGGY CODE ###

import sys,math,copy
import numpy as np
input = sys.stdin.readline
S = [int(x) if x != '?' else -1 for x in input().strip()]
N = len(S)

dp = np.zeros((13), dtype=int)
dp_ = np.zeros((13), dtype=int)
mod13_list = [i % 13 for i in range(12 ** 2 + 1)]
divisor = 10 ** 9 + 7
dp_[0] = 1
mul = 1
for i, s in enumerate(S[::-1], start=1):
    if s == -1:
        for d in range(10):
            m = mod13_list[(d * mul)]
            for pm in range(13):
                dp[mod13_list[(pm+m)]] = dp[mod13_list[(pm+m)]] + dp_[pm]

    else:
        m = mod13_list[(s * mul)]
        for pm in range(13):
            dp[mod13_list[(pm+m)]] = dp_[pm]
    dp_ = dp % divisor
    dp = dp * 0 # np.zeros((13), dtype=int)
    mul = mod13_list[(mul * 10)]
print(dp_[5] % divisor)

### FIXED CODE ###

import sys,math,copy

def main():
    # import numpy as np
    input = sys.stdin.readline
    S = ''.join(reversed(input().strip()))

    # dp = np.zeros((13), dtype=int)
    # dp_ = np.zeros((13), dtype=int)
    dp = [0] * 13
    dp_ = [0] * 13
    mod13_list = [i % 13 for i in range(12 ** 2 + 1)]
    list10 = list(range(10))
    list13 = list(range(13))
    divisor = 10 ** 9 + 7
    dp_[0] = 1
    mul = 1
    for i in range(len(S)):
        s = S[i]
        if s == '?':
            for d in list10:
                m = mod13_list[(d * mul)]
                for pm in list13:
                    dp[mod13_list[(pm+m)]] += dp_[pm]

        else:
            si = int(s)
            m = mod13_list[(si * mul)]
            for pm in list13:
                dp[mod13_list[(pm+m)]] = dp_[pm]

        # dp_ = dp % divisor
        # dp = dp * 0 # np.zeros((13), dtype=int)
        for j in list13:
            dp_[j] = dp[j] % divisor
            dp[j] = 0
        mul = mod13_list[(mul * 10)]
    print(dp_[5])

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

a, b, k = map(int, input().split())
for i in range(a, b + 1):
    if i - a + 1 <= k or b - i + 1 <= k:
        print(i)


### FIXED CODE ###

a, b, k = map(int, input().split())
ans = []
for i in range(a, min(a + k, b + 1)):
    ans.append(i)
for i in range(b, max(b - k, a - 1), -1):
    if i not in ans:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)
### BUGGY CODE ###

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    S = S[::-1]

    dp = [0] * 13
    dp[0] = 1
    p = 1

    for c in S:
        dp, dp_prev = [0] * 13, dp
        for k in range(13):
            if c == '?':
                for j in range(10):
                    dp[(p * j + k) % 13] = (dp[(p * j + k) % 13] + dp_prev[k]) % MOD
            else:
                dp[(p * int(c) + k) % 13] = (dp[(p * int(c) + k) % 13] + dp_prev[k]) % MOD

        p = p * 10 % 13

    print(dp[5])
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    N = len(S)
    power = [0] * N
    power[0] = 1
    for i in range(N - 1):
        power[i + 1] = 10 * power[i] % 13

    S = S[::-1]

    Q = [i for i, c in enumerate(S) if c == '?']
    M = len(Q)

    const = 0
    for i, c in enumerate(S):
        if c != '?':
            const = (const + power[i] * int(c)) % 13

    dp = [0] * 13
    dp[const] = 1

    for i in range(M):
        dp, dp_prev = [0] * 13, dp
        p = power[Q[i]]
        for j in range(10):
            for k in range(13):
                idx = (p * j + k) % 13
                dp[idx] = (dp[idx] + dp_prev[k]) % MOD

    print(dp[5])
    return


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

import sys
readline = sys.stdin.buffer.readline
from collections import defaultdict
dic1 = defaultdict(int)

def even(n): return 1 if n%2==0 else 0


H,W,M = map(int,readline().split())

columns = [0]*W
row = [0]*H
for i in range(M):
    h,w = map(int,readline().split())
    h,w = h-1,w-1
    dic1[(h,w)] = 1
    columns[w] += 1
    row[h] += 1

def rank(lst,syoujun=False):
    res2 = list(set(lst))
    ans = []
    if syoujun:
        res2.sort()
    else:
        res2.sort(reverse=True)
    dic1 = dict()
    for i in range(len(res2)):
        dic1[res2[i]] = i
    for idx,i in enumerate(lst):
        if dic1[i] == 0:
            ans.append(idx)
    
    return ans

col2 = rank(columns)
row2 = rank(row)

ans = 0
for i in col2:
    for j in row2:
        if dic1[(j,i)]:
            ans = max(ans,columns[i]+row[j]-1)
        else:
            ans = max(ans,columns[i]+row[j])

print(ans)

### FIXED CODE ###

import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0


H,W,M = map(int,readline().split())

col = [0]*W
row = [0]*H
elements = []
for i in range(M):
    h,w = map(int,readline().split())
    h,w = h-1,w-1
    elements.append((h,w))
    col[w] += 1
    row[h] += 1

def rank(lst,syoujun=False):
    res2 = list(set(lst))
    ans = []
    if syoujun:
        res2.sort()
    else:
        res2.sort(reverse=True)
    dic1 = dict()
    for i in range(len(res2)):
        dic1[res2[i]] = i
    for i in lst:
        #ans.append(dic1[i]) #zero-indexed
        ans.append(dic1[i] + 1) #one-indexed
    
    return ans

col2 = rank(col)
row2 = rank(row)

cmax = col2.count(1)
rmax = row2.count(1)

counter = 0
for i,j in elements:
    if col2[j] == 1 and row2[i] == 1:
        counter += 1

if counter == cmax*rmax:
    print(max(col) + max(row)-1)
else:
    print(max(col) + max(row))
### BUGGY CODE ###

import sys
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
N = II()
A = list(MI())
ans = 0
cum = {}
def couple_combination(n):
    if n >= 2:
        return int(n * (n - 1) / 2)
    else:
        return 0
for unique in list(set(A)):
    cum_count = A.count(unique)
    cum[unique] = cum_count
    ans += couple_combination(cum_count)
for i in A:
    print(max(0,ans - cum[i] + 1))


### FIXED CODE ###

import sys
from collections import defaultdict
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
N = II()
A = list(MI())
ans = 0
cum = defaultdict(int)
def couple_combination(n):
    if n >= 2:
        return int(n * (n - 1) / 2)
    else:
        return 0
for v in A:
    cum[v] += 1
for v in cum.values():
    ans += couple_combination(v)
for v in A:
    print(max(0,ans - cum[v] + 1))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
mod = 7 + 10 ** 9
lcm = lcm(*A)
ans = 0
for i in A:
    ans += lcm // i
    ans %= mod
print(ans) 

### FIXED CODE ###

import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
A = sorted(A, reverse=True)
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
mod = 7 + 10 ** 9
lcm = lcm(*A)
ans = 0
for i in A:
    ans += lcm // i
print(ans % mod)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
def IN(): return map(int,input().split())
def main():
  h,n=IN()
  A=[]; dp=[pow(10,9)]*(h+10)
  for i in range(n):
    x,y=IN()
    A.append((x,y))
  dp[0]=0
  for a,b in A:
    for i in range(h):
      if dp[i]==pow(10,9): continue
      index=min(h,i+a)
      dp[index]=min(dp[index],dp[i]+b)
  print(dp[h])
main()

### FIXED CODE ###

def IN(): return map(int,input().split())
ans = pow(2,31); mod = pow(10,9)+7
h,n=IN()
A=[]; dp=[pow(2,31)]*111111
for i in range(n):
  x,y=IN()
  A.append((x,y))
dp[0]=0
for a,b in A:
  for i in range(h+1111):
    dp[i+a]=min(dp[i+a],dp[i]+b)
for i in range(h,11111):
  ans=min(ans,dp[i])
print(ans)
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

N = INT()
a = LIST()

a_cnt = Counter(a)
num_1 = a_cnt[1]
num_2 = a_cnt[2]
num_3 = a_cnt[3]

dp = [[[0]*(302) for _ in range(302)] for _ in range(302)]

@lru_cache(maxsize=None)
def rec(i, j, k):
	if i==0 and j==0 and k==0: return 0.0

	res = 0
	if i > 0: res += rec(i-1, j, k)*i
	if j > 0: res += rec(i+1, j-1, k)*j
	if k > 0: res += rec(i, j+1, k-1)*k
	res += N
	res /= (i+j+k)
	dp[i][j][k] = res
	return res

print(rec(num_1, num_2, num_3))


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

N = INT()
a = LIST()

a_cnt = Counter(a)
num_1 = a_cnt[1]
num_2 = a_cnt[2]
num_3 = a_cnt[3]

dp = [[[0.0]*(301) for i in range(301)] for j in range(301)]
 
for i in range(1, N+1):
    for j in range(min(i, num_2+num_3)+1):
        for k in range(min(j, num_3)+1):
            s = i-j
            t = j-k
            res = 0
            if s > 0:
                res += dp[s-1][t][k]*s  
            if t > 0:
                res += dp[s+1][t-1][k]*t
            if k > 0:
                res += dp[s][t+1][k-1]*k
            res += N
            res /= (s+t+k)

            dp[s][t][k] = res

print(dp[num_1][num_2][num_3])
### BUGGY CODE ###

import collections
N = input()
inp = map(int, input().split())
dic = dict(collections.Counter(inp))
wa = 0
for i in range(len(dic)):
    wa += list(dic.keys())[i] * list(dic.values())[i]
se = set(dic.keys())
for i in range(int(input())):
    a, b = map(int, input().split())
    if a in se:
        wa += dic[a] * (b-a)
        if b in se:
            pass
        else:
            dic[b] = 0
        se.add(b)
        dic[b] += dic[a]
        dic[a] = 0
    print(wa)

### FIXED CODE ###

import collections
N = int(input())
inp = list(map(int,input().split()))
dic = dict(collections.Counter(inp))
wa = 0
for i, j in dic.items():
	wa += i * j
se = set(dic.keys())
for i in range(int(input())):
	a, b = map(int,input().split())
	if a in se:
		wa += dic[a] * (b-a)
		if b in se:
			pass
		else:
			dic[b] = 0
		se.add(b)
		dic[b] += dic[a]
		dic[a] = 0
	print(wa)
### BUGGY CODE ###

def solve(n, a):
    for i in range(n - 1):
        for j in range(i + 1, n):
            if(a[i] == a[j]):
                return 'NO'

    return 'YES'

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

print(solve(n, a))

### FIXED CODE ###

def solve(n, a):
    a.sort()
    for i in range(n - 1):
        if(a[i] == a[i + 1]):
            return 'NO'

    return 'YES'

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

print(solve(n, a))
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().strip()

def main():
    H, W, M = map(int, input().split())
    bomb = set()
    yoko = [0] * W
    tate = [0] * H
    for _ in range(M):
        h, w = map(int, input().split())
        bomb.add((h-1, w-1))
        yoko[w - 1] += 1
        tate[h - 1] += 1

    idx_yoko = [(yoko[i], i) for i in range(W)]
    idx_tate = [(tate[i], i) for i in range(H)]
    idx_yoko.sort(reverse=True, key=lambda x: (x[0], x[1]))
    idx_tate.sort(reverse=True, key=lambda x: (x[0], x[1]))
    ans = 0
    for p in range(min(5000, W)):
        for q in range(min(5000, H)):
            yoko_bomb, idx_w = idx_yoko[p]
            tate_bomb, idx_h = idx_tate[q]
            get_bomb = yoko_bomb + tate_bomb
            if (idx_h, idx_w) in bomb: get_bomb -= 1
            ans = max(ans, get_bomb)
    print(ans)



if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()

def main():
    H, W, M = map(int, input().split())
    bomb = set()
    yoko = [0] * W
    tate = [0] * H
    for _ in range(M):
        h, w = map(int, input().split())
        bomb.add((h-1, w-1))
        yoko[w - 1] += 1
        tate[h - 1] += 1

    idx_yoko = [(yoko[i], i) for i in range(W)]
    idx_tate = [(tate[i], i) for i in range(H)]
    idx_yoko.sort(reverse=True, key=lambda x: (x[0], x[1]))
    idx_tate.sort(reverse=True, key=lambda x: (x[0], x[1]))
    ans = 0

    yoko_bomb, idx_w = idx_yoko[0]
    tate_bomb_max = idx_tate[0][0]
    for tate_bomb, idx_h in idx_tate:
        if tate_bomb != tate_bomb_max: break
        if (idx_h, idx_w) not in bomb:
            print(yoko_bomb + tate_bomb)
            return

    tate_bomb, idx_h = idx_tate[0]
    yoko_bomb_max = idx_yoko[0][0]
    for yoko_bomb, idx_w in idx_yoko:
        if yoko_bomb != yoko_bomb_max: break
        if (idx_h, idx_w) not in bomb:
            print(yoko_bomb + tate_bomb)
            return

    print(yoko_bomb_max + tate_bomb_max - 1)
    

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

import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    n = int(input())
    s = [sorted(list(input())) for _ in range(n)]
    ans = 0

    for i in range(n):
        for k in range(i+1, n):
            if s[i] == s[k]:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import collections


def input():
    return sys.stdin.readline()[:-1]


def main():
    n = int(input())
    s = ["".join(sorted(list(input()))) for _ in range(n)]
    c = collections.Counter(s)
    ans = 0
    for k in c.values():
        ans += k*(k-1)//2

    print(ans)


if __name__ == '__main__':
    main()