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

from fractions import gcd
import sys
input = sys.stdin.readline

'''def gcd(a,b):
  if a%b==0:
    return b
  else:
    return gcd(b,a%b)'''



n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=1)
ans=0
m=int(10**9+7)
g=1
l=1
for x in a:
  if l%x!=0:
    g=gcd(l,x)
    l=l*x//g

for x in a:
  ans+=(l//x)%m

print(ans%m)

### FIXED CODE ###

from fractions import gcd
from functools import reduce
import sys
input = sys.stdin.readline

'''def gcd(a,b):
  if a%b==0:
    return b
  else:
    return gcd(b,a%b)'''


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=1)
ans=0
m=int(10**9+7)
g=1
l=1
'''
for x in a:
  if l%x!=0:
    g=gcd(l,x)
    l=l*x//g
'''
l=lcm(*a)

for x in a:
  ans+=l//x

print(ans%m)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
S = readline()
count = 0
for i in range(0,1000):
    c = [i//100,(i//10)%10,i%10]
    f = 0
    for j in range(0,N):
        if int(S[j]) == int(c[f]):
            f += 1
        if f == 3:
            break
    if f == 3:
        count += 1
            
print(count)


### FIXED CODE ###

#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
S = readline()
count = 0
for i in range(10):
    a = S.find(str(i))
    if a == -1: 
        continue
    for j in range(10):
        b = S.find(str(j),a+1)
        if b == -1: 
            continue
        for k in range(10):
            c = S.find(str(k),b+1)
            if c != -1: count +=1
print(count)
### BUGGY CODE ###

R, G, B, N = map(int, input().split())
ans = 0
for x in range(N // R + 1):
	for y in range(N // G + 1):
		if (N - R * x - G * y) % B == 0 and 0 <= (N - R * x - G * y) // B <= N // B:
			ans += 1
print(ans)

### FIXED CODE ###

R, G, B, N = map(int, input().split())
ans = 0
 
for Rx in range(0, N+1, R):
    for Gy in range(0, N+1, G):
        check = N - Rx - Gy
        if check % B == 0 and 0 <= check // B <= N // B:
            ans += 1
print(ans)
### BUGGY CODE ###

import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,int(math.log2(N)))):
	B = [0]*N
	for i in range(N):
		l = max(0,i-A[i])
		r = min(N-1,i+A[i])
		B[l] += 1
		if r < N-1:
			B[r+1] -= 1
	for i in range(1,N):
		B[i] += B[i-1]
	A = B
print(' '.join(map(str,A)))


### FIXED CODE ###

import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
for j in range(min(K,50)):
	B = [0]*N
	for i in range(N):
		l = max(0,i-A[i])
		r = min(N-1,i+A[i])
		B[l] += 1
		if r < N-1:
			B[r+1] -= 1
	for i in range(1,N):
		B[i] += B[i-1]
	A = B
print(' '.join(map(str,A)))
### BUGGY CODE ###

start,end,devide = map(int,input().split())
num = 0
for i in range(start,end + 1):
  if i % devide == 0:
    num +=1
    num += (end - i) // devide
    break
print(num)

### FIXED CODE ###

a, b, x  = map(int, input().split())
 
if a != 0:
	print(b//x - (a-1)//x)
else:
	print(b//x + 1)
### BUGGY CODE ###

from collections import defaultdict
def solve():
    N = int(input())
    S2 = [0]*(2*N)
    for i in range(N):
        S2[i] = input()*2
        S2[i+N] = S2[i]
    check = defaultdict(lambda: [[0]*(2*N) for _ in range(2*N)])
    cum = defaultdict(lambda: [[0]*(2*N) for _ in range(2*N)])
    for i in range(2*N-1):
        for j in range(2*N-1):
            for k in range(max([-N+1,i+1-2*N,-j]),min([N,2*N-j,i+1])):
                check[k][i+1][j+1] = S2[i][j]==S2[j+k][i-k]
    for i in range(1,2*N):
        for j in range(1,2*N):
            for k in range(-N+1,N):
                cum[k][i][j] = cum[k][i-1][j]+cum[k][i][j-1]-cum[k][i-1][j-1]+check[k][i][j]
                if i>=N+1:
                    cum[k][i][j] -= check[k][i-N][j]
                if j>=N+1:
                    cum[k][i][j] -= check[k][i][j-N]
                if i>=N+1 and j>= N+1:
                    cum[k][i][j] += check[k][i-N][j-N]
    ans = 0
    for k in range(-N+1,0):
        A,B = -k+N,N
        while A<2*N:
            if cum[A-B][A][B]==N*N:
                ans += 1
            A += 1
            B += 1
    for k in range(N):
        A,B = N,k+N
        while B<2*N:
            if cum[A-B][A][B]==N*N:
                ans += 1
            A += 1
            B += 1
    return ans
print(solve())

### FIXED CODE ###

def solve():
    N = int(input())
    S2 = [0]*N
    for i in range(N):
        S2[i] = input()
    ans = 0
    for k in range(N):
        cum = [[0]*(N+1) for _ in range(N+1)]
        for i in range(1,N+1):
            for j in range(1,N+1):
                cum[i][j] = cum[i-1][j]+cum[i][j-1]-cum[i-1][j-1]+(S2[i-1][j-1]==S2[(j-1+k)%N][(i-1-k)%N])
                if i==N and j==N:
                    ans += (cum[i][j]==N*N)*N
    return ans
print(solve())
### BUGGY CODE ###

import numpy as np

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

result=0
for i in range(n-1):
  for j in range(i+1,n):
    temp=a[i]+a[j]
    #print(a[i],a[j],a[j+1:])
    result+=max(0,np.count_nonzero(a[j+1:] < temp))

print(result)

### FIXED CODE ###

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

l.sort()
l.append(10**9)
cnt=0
i=0
#print(l)

while i<n-2:
    j=i+1
    while j<n-1:
        LL=j+1
        RR=n-1
        #print("#",l[i],l[j],l[LL],l[RR])
        while LL<=RR:
            k=(LL+RR)//2
            if k==n:
                break
            #print(l)
            #print(i,j,LL,RR,k)
            #print(l[i]+l[j],l[k],l[k+1])
            if l[i]+l[j]>l[k] and l[i]+l[j]<=l[k+1]:
                cnt+=k-j
                break
            elif LL==RR:
                break
            elif l[i]+l[j]<=l[k]:
                RR=k
            elif l[i]+l[j]>l[k]:
                LL=k+1
            elif l[i]+l[j]<l[k] and k==j+1:
                break
        j+=1
    i+=1

print(cnt)
### BUGGY CODE ###

N = int(raw_input())
nums = map(int, raw_input().split())
num_t = []
index_t = []
for i,num in enumerate(nums):
    num_t.append([num, i])
num_t = sorted(num_t, key=lambda x: x[0])
for a in num_t:
    index_t.append(a[1])
for i in range(N):
    num_tmp = num_t
    idx = index_t.index(i)
    num_tmp = num_tmp[0:idx] + num_tmp[idx+1:N]
    print(num_tmp[(N/2) - 1][0])



### FIXED CODE ###

N = int(raw_input())
nums = map(int, raw_input().split())
num_tmp = []
for a in nums:
    num_tmp.append(a)
nums.sort()
med_1 = nums[N/2 - 1]
med_2 = nums[N/2]
for i in range(N):
    if num_tmp[i] <= med_1:
        print(med_2)
    elif num_tmp[i] >= med_2:
        print(med_1)
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
for i in range(q):
    l, r = map(int, input().split())
    print(s[l-1:r].count("AC"))

### FIXED CODE ###

n, q = map(int, input().split())
s = input()

lc = [0]
c = 0
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        c += 1
    lc.append(c)

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

import sys
sys.setrecursionlimit(10 ** 5)

N, M = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(M):
  X,Y,Z = map(int, input().split())
  X -= 1
  Y -= 1
  G[X].append(Y)
  G[Y].append(X)
#print(G)

def dfs(u,v):
  for t in G[u]:
    #if t != v:
    if not Visited[t]:
      Visited[t] = True
      dfs(t,u)

Visited = [False for _ in range(N)]
ans = 0
for i in range(N):
  if not Visited[i]:
    Visited[i] = True
    ans += 1
    dfs(i,-1)
print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

N, M = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(M):
  X,Y,Z = map(int, input().split())
  X -= 1
  Y -= 1
  G[X].append(Y)
  G[Y].append(X)
#print(G)

def dfs(u,v):
  for t in G[u]:
    #if t != v:
    if not Visited[t]:
      Visited[t] = True
      dfs(t,u)

Visited = [False for _ in range(N)]
ans = 0
for i in range(N):
  if not Visited[i]:
    Visited[i] = True
    ans += 1
    dfs(i,-1)
print(ans)
### BUGGY CODE ###

def gen(x):
    root = int(pow(x, 0.5))

    yield x

    for k in range(2, root):
        if x % k == 0:
            yield k
            yield x // k

    if x % root == 0:
        yield root
        if root * root != x:
            yield x // root


def main():
    N = int(input())

    # N%K!=0
    cnt = len(tuple(gen(N - 1)))

    # N%K==0
    for k in gen(N):
        x = N
        while x % k == 0:
            x //= k

        if x % k == 1:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def gen(x):
    root = int(pow(x, 0.5))
    for k in range(1, root + 1):
        if x % k == 0:
            yield k
            if k != x // k:
                yield x // k


def main():
    N = int(input())

    # N%K!=0
    cnt = sum(1 for _ in filter(lambda x: x > 1, gen(N - 1)))

    # N%K==0
    for k in filter(lambda x: x > 1, gen(N)):
        x = N
        while x % k == 0:
            x //= k

        if x % k == 1:
            cnt += 1

    print(cnt)


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

N = int(input())
line = list(map(int,input().split()))
a = 0
p = []
for i in line:
    p.append(i)
    if  min(p) >= i:
       a += 1

print(a)

### FIXED CODE ###

N = int(input())
line = list(map(int,input().split()))
a = 1
m = line[0]
for i in range(N-1):
    if m >= line[i]:
        m = line[i]

    if m >= line[i+1]:
       a += 1

print(a)
### BUGGY CODE ###

import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    s = input()
    q = int(input())
    ans = deque()
    swap = False
    for i in range(len(s)):
        ans.append(s[i])

    for i in range(q):
        #print(ans, swap)
        inp = input()
        if len(inp) == 1:
            hoge = int(inp)
            if swap:
                swap = False
            else:
                swap = True
        else:
            # print(tuple(inp))
            fi, ci = tuple(inp)[2], tuple(inp)[4]
                       
            if int(fi) == 1:
                if not swap:
                    ans.appendleft(ci)
                else:
                    ans.append(ci)
            if int(fi) == 2:
                if not swap:
                    ans.append(ci)
                else:
                    ans.appendleft(ci)
    s_ans = str()
    ans = list(ans)
    if swap:
        for i in range(len(ans)-1,-1, -1):
            s_ans += ans[i]
    else:
        for i in range(len(ans)):
            s_ans += ans[i]
    
    print(s_ans)
                
    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    s = input()
    q = int(input())
    ans = deque()
    swap = False
    for i in range(len(s)):
        ans.append(s[i])

    for i in range(q):
        #print(ans, swap)
        inp = input()
        if len(inp) == 1:
            hoge = int(inp)
            if swap:
                swap = False
            else:
                swap = True
        else:
            # print(tuple(inp))
            fi, ci = tuple(inp)[2], tuple(inp)[4]
                       
            if int(fi) == 1:
                if not swap:
                    ans.appendleft(ci)
                else:
                    ans.append(ci)
            if int(fi) == 2:
                if not swap:
                    ans.append(ci)
                else:
                    ans.appendleft(ci)
    s_ans = str()
    ans = list(ans)
    if swap:
        for i in range(len(ans)-1,-1, -1):
            s_ans += ans[i]
    else:
        for i in range(len(ans)):
            s_ans += ans[i]
    
    print(s_ans)
                
    return

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

n,m = map(int,input().split(" "))
def bar_M(t):
    return int(t)%m
array = list(map(bar_M,input().split(" ")))

array_sum = [0 for i in range(n+1)]
for i in range(1,n+1):
    array_sum[i] = (array_sum[i-1] + array[i-1])%m

nums = set(array_sum)
sums = []
for i in nums:
    p = array_sum.count(i)
    if p > 1:
        sums.append(array_sum.count(i))
ans = 0
for i in sums:
    ans+=int((i-1)*i/2)
print(ans)

### FIXED CODE ###

n,m = map(int,input().split(" "))
array = list(map(int,input().split(" ")))

array_sum,sums = [0,0],{0:1}
for i in range(1,n+1):
    array_sum[0] = array_sum[1]
    array_sum[1] = (array_sum[0] + array[i-1])%m
    sums[array_sum[1]] = sums.get(array_sum[1],0) + 1

ans = 0
for i in sums.values():
    ans+=int((i-1)*i/2)
print(ans)
### BUGGY CODE ###

def cnt_ac(S):
    N = len(S)
    L = []
    R = []
    for i in range(0,N-1,2):
        L.append(S[i]+S[i+1])
    for i in range(1,N-1,2):
        R.append(S[i]+S[i+1])
    return L.count('AC')+R.count('AC')

N, Q = map(int,input().split())
S = input()
ans = []

for i in range(Q):
    L, R = map(int,input().split())
    T = S[L-1 : R]
    ans.append(cnt_ac(T))

for i in ans:
    print(i)


### FIXED CODE ###

N, Q = map(int,input().split())
S = input()
T = [0]*(N+1)
for i in range(N):
    T[i+1] = T[i] + (1 if S[i : i+2] == 'AC' else 0)

for i in range(Q):
    L, R = map(int,input().split())
    print(T[R-1] - T[L-1])
### 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 permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
a = LIST()
count = 0
flag = 0
while flag == 0:	
	for i in range(N):
		if a[i] % (1024**3) == 0:
			a[i] /= (1024**3)
			count += 30
			break
	else:
		flag = 1
flag = 0
while flag == 0:
	for i in range(N):
		if a[i] % 2 == 0:
			a[i] /= 2
			count += 1
			break
	else:
		flag = 1
print(count)

### 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 permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
a = LIST()
count = 0
flag = 0
"""
while flag == 0:
	print(a)
	for i in range(N):
		if a[i] % 2 == 0:
			a[i] = int(a[i]/2)
			count += 1
			break
	else:
		flag = 1
"""
for i in a:
    while i % 2 == 0:
        count += 1
        i /= 2
print(count)
### BUGGY CODE ###

k, s = list(map(int, input().split()))

count = 0

for p in range(k+1):
    if p > s:
        break
    for q in range(k+1):
        if p + q > s:
            break
        for r in range(k+1):
            t = p + q + r
            if t == s:
                count += 1
                break
print(count)


### FIXED CODE ###

k, s = list(map(int, input().split()))
count = 0

for p in range(k+1):
    for q in range(k+1):
        r = s-p-q
        if r>=0 and r<=k:
            count += 1

print(count)
### BUGGY CODE ###

N = int(input())
S = input()

res = 0

Rs = [i for i in range(N) if S[i] == 'R']
Gs = [i for i in range(N) if S[i] == 'G']
Bs = [i for i in range(N) if S[i] == 'B']

for r in Rs:
  for g in Gs:
    for b in Bs:
      i, j, k = sorted([r, g, b])
      if j - i != k - j:
        res += 1

print(res)


### FIXED CODE ###

N = int(input())
S = input()

res = 0

Rn = S.count('R')
Gn = S.count('G')
Bn = S.count('B')

res = Rn * Gn * Bn

for p in range(1, N - 1):
  for q in range(1, min(p, N - p - 1) + 1):
    i, j, k = p - q, p, p + q
    if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
      res -= 1

print(res)
### BUGGY CODE ###

n, x = tuple(map(int, input().split()))
points = [int(x) for x in input().split()]
points.append(x)
points.sort()

ds = [points[i + 1] - points[i] for i in range(len(points) - 1)]
for m in range(min(ds), 0, -1):
    if all([x % m == 0 for x in ds]):
        print(m)
        break


### FIXED CODE ###

from functools import reduce

def euclid(a, b):
    if a < b:
        a, b = (b, a)

    while True:
        r = a % b
        if r == 0:
            break
        a, b = (b, r)

    return b


if __name__ == '__main__':
    n, x = tuple(map(int, input().split()))
    points = [int(x) for x in input().split()]

    buf = [abs(p - x) for p in points]
    print(reduce(lambda a,b: euclid(a, b), buf))
### BUGGY CODE ###

# 愚直な方法: O(n^2)
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
cnt = 0
for i in range(1, n+1):
    for j in range(i+1, n+1):
        if abs(i-j) == (a[i-1]+a[j-1]):
            cnt += 1
print(cnt)

### FIXED CODE ###

from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
ci = defaultdict(int)
cj = defaultdict(int)
for i in range(n):
    ci[a[i]+i] += 1
    cj[i-a[i]] += 1
cnt = 0
for k in ci.keys():
    cnt += ci[k] * cj[k]
print(cnt)
### BUGGY CODE ###

n, k = map(int, input().split())
*A, = map(int, input().split())
p = 10**9+7
DP = [[None for j in range(k+1)] for i in range(n+1)]
for i in range(n+1):
    DP[i][0] = 1
for j in range(1, k+1):
    DP[0][j] = 0
for i in range(1, n+1):
    for j in range(1, k+1):
        DP[i][j] = (DP[i][j-1]+DP[i-1][j]) % p
        if j > A[i-1]:
            DP[i][j] = (DP[i][j]-DP[i-1][j-1-A[i-1]]) % p
print(DP[n][k])


### FIXED CODE ###

n, k = map(int, input().split())
*A, = map(int, input().split())
p = 10**9+7
DP = [[None for j in range(k+1)] for i in range(n+1)]
for i in range(n+1):
    DP[i][0] = 1
for j in range(1, k+1):
    DP[0][j] = 0
for i in range(1, n+1):
    for j in range(1, k+1):
        DP[i][j] = (DP[i][j-1]+DP[i-1][j]) % p
        if j > A[i-1]:
            DP[i][j] = (DP[i][j]-DP[i-1][j-1-A[i-1]]) % p
print(DP[n][k])
### BUGGY CODE ###

A, B, Q = map(int, input().split())
s = []
for i in range(A):
    s.append(int(input()))
s.sort()
t = []
t.sort()
for i in range(B):
    t.append(int(input()))
x = []
for i in range(Q):
    x.append(int(input()))

for i in range(Q):
    sx, tx, sy, ty = [], [], [], []
    for j in s:
        sx.append(abs(j - x[i]))
    for j in t:
        tx.append(abs(j - x[i]))
    sxi = sx.index(min(sx))
    txi = tx.index(min(tx))
    for j in t:
        ty.append(abs(j - s[sxi]))
    for j in s:
        sy.append(abs(j - t[txi]))
    a = min(sx) + min(ty)
    b = min(tx) + min(sy)
    if a < b:
        print(str(a))
    else:
        print(str(b))


### FIXED CODE ###

import bisect

A, B, Q = map(int, input().split())
INF = 10**18
S = [-INF]
for i in range(A):
    S.append(int(input()))
S.append(INF)
T = [-INF]
for i in range(B):
    T.append(int(input()))
T.append(INF)
X = []
for i in range(Q):
    X.append(int(input()))

for x in X:
    a, b = bisect.bisect_right(S, x), bisect.bisect_right(T, x)
    print(min(abs(s-t) + min(abs(s-x), abs(t-x))
              for s in S[a-1:a+1] for t in T[b-1:b+1]))
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in range(N):
  ans *= A[i]
if ans > 1e18:
  ans = -1
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = 1
check = (0 in A)
if check:
  print(0)
else:
  for i in range(N):
    ans *= A[i]
    if ans > 1e18:
      ans = -1
      break
  print(ans)
### BUGGY CODE ###

s = list(str(input()))
q = int(input())
hanten = 0

for i in range(q):
    x = input().split()
    if len(x) == 1:
        t = x[0]
        if t == "1" and hanten == 0:
            hanten = 1
        elif t == "1" and hanten == 1:
            hanten = 0

    else:
        f = int(x[1])
        c = str(x[2])
        if f == 1 and hanten == 0:
            s.insert(0, c)

        elif f == 1 and hanten == 1:
            s.append(c)

        elif f == 2 and hanten == 0:
            s.append(c)

        elif f == 2 and hanten == 1:
            s.insert(0, c)

else:
    d = len(s)
    if hanten == 1:
        for i in range(d):
            print(s[d-1-i], end="")
    else:
        for i in range(d):
            print(s[i], end="")


### FIXED CODE ###

from collections import deque

s = deque(str(input()))
q = int(input())
hanten = 0

for i in range(q):
    x = input().split()
    if len(x) == 1:
        t = x[0]
        if t == "1" and hanten == 0:
            hanten = 1
        elif t == "1" and hanten == 1:
            hanten = 0

    else:
        f = int(x[1])
        c = str(x[2])
        if f == 1 and hanten == 0:
            s.appendleft(c)

        elif f == 1 and hanten == 1:
            s.append(c)

        elif f == 2 and hanten == 0:
            s.append(c)

        elif f == 2 and hanten == 1:
            s.appendleft(c)

else:
    if hanten == 1:
        s.reverse()

print("".join(s))
### BUGGY CODE ###

N = int(input())
A = [-1, -1] + list(map(int, input().split()))
for i in range(1, N+1):
    print(A.count(i))


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = [0 for i in range(N)]
for i in range(N-1):
    B[A[i]-1] += 1
print("\n".join(list(map(str, B))))
### BUGGY CODE ###

n=int(input())
a=[list(input()) for i in range(n)]
count=0
for i in range(len(a)):
    for j in range(i+1,len(a)):
        lst=a[i].copy()
        for element in a[j]:
            if element in lst:
                lst.remove(element)
        if len(lst)==0:
            count+=1
print(count)

### FIXED CODE ###

import math
import collections

n=int(input())
a=[list(input()) for i in range(n)]
b=[str(sorted(list(i))) for i in a]
count=list(collections.Counter(b).values())
count=[i for i in count if i>1]
print(int(sum([math.factorial(x)/(math.factorial(x-2)*2) for x in count])))