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

def main():
    S = raw_input()
    Q = int(raw_input())

    is_reversed = False

    for _ in range(Q):
        query = raw_input().split()
        if query[0] == "1":
            is_reversed = not is_reversed
        elif query[0] == "2":
            F = int(query[1])
            C = query[2]
            if F == 1:
                if not is_reversed:
                    S = "".join([C, S])
                else:
                    S = "".join([S, C])
            elif F == 2:
                if not is_reversed:
                    S = "".join([S, C])
                else:
                    S = "".join([C, S])


    if not is_reversed:
        ans =  S
    else:
        ans = S[::-1]
    print ans

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    S = raw_input()
    Q = int(raw_input())

    is_reversed = False
    sentou = []
    owari = []

    for _ in range(Q):
        query = raw_input().split()
        if query[0] == "1":
            is_reversed = not is_reversed
        elif query[0] == "2":
            F = query[1]
            C = query[2]
            if F == "1":
                if not is_reversed:
                    sentou.append(C)
                else:
                    owari.append(C)
            elif F == "2":
                if not is_reversed:
                    owari.append(C)
                else:
                    sentou.append(C)

    S = "".join(sentou[::-1]+list(S)+owari)


    if not is_reversed:
        print S
    else:
        print S[::-1]

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

from sys import stdin
from collections import deque

H, W = [int(x) for x in stdin.readline().rstrip().split()]
maze = [stdin.readline().rstrip().split()[0] for _ in range(H)]

d = [[0] * W for _ in range(H)]

for h in range(H):
    for w in range(W):
        q = deque([(h, w, 0)])
        if maze[h][w] == '#':
            continue
        else:
            temp_h = h
            temp_w = w
            visited = [[0] * W for _ in range(H)]
            while len(q) > 0:
                temp = q.popleft()
                temp_h = temp[0]
                temp_w = temp[1]
                temp_d = temp[2]
                d[h][w] = max(d[h][w], temp_d)
                visited[temp_h][temp_w] = 1
                if temp_h + 1 < H and maze[temp_h + 1][temp_w] == '.' and visited[temp_h + 1][temp_w] == 0:
                    q.append((temp_h + 1, temp_w, temp_d + 1))
                if temp_h - 1 >= 0 and maze[temp_h - 1][temp_w] == '.' and visited[temp_h - 1][temp_w] == 0:
                    q.append((temp_h - 1, temp_w, temp_d + 1))
                if temp_w + 1 < W and maze[temp_h][temp_w + 1] == '.' and visited[temp_h][temp_w + 1] == 0:
                    q.append((temp_h, temp_w + 1, temp_d + 1))
                if temp_w - 1 >= 0 and maze[temp_h][temp_w - 1] == '.' and visited[temp_h][temp_w - 1] == 0:
                    q.append((temp_h, temp_w - 1, temp_d + 1))

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, d[i][j])
print(ans)

### FIXED CODE ###

from sys import stdin
import queue

H, W = [int(x) for x in stdin.readline().rstrip().split()]
maze = [stdin.readline().rstrip().split()[0] for _ in range(H)]

ans = 0

for h in range(H):
    for w in range(W):
        if maze[h][w] == '#':
            continue
        else:
            q = queue.Queue()
            q.put((h, w))
            visited = [[-1] * W for _ in range(H)]
            visited[h][w] = 0
            while q.qsize() > 0:
                temp = q.get()
                temp_h = temp[0]
                temp_w = temp[1]
                ans = max(ans, visited[temp_h][temp_w])
                if temp_h + 1 < H and maze[temp_h + 1][temp_w] == '.' and visited[temp_h + 1][temp_w] < 0:
                    visited[temp_h + 1][temp_w] = visited[temp_h][temp_w] + 1
                    q.put((temp_h + 1, temp_w))
                if temp_h - 1 >= 0 and maze[temp_h - 1][temp_w] == '.' and visited[temp_h - 1][temp_w] < 0:
                    visited[temp_h - 1][temp_w] = visited[temp_h][temp_w] + 1
                    q.put((temp_h - 1, temp_w))
                if temp_w + 1 < W and maze[temp_h][temp_w + 1] == '.' and visited[temp_h][temp_w + 1] < 0:
                    visited[temp_h][temp_w + 1] = visited[temp_h][temp_w] + 1
                    q.put((temp_h, temp_w + 1))
                if temp_w - 1 >= 0 and maze[temp_h][temp_w - 1] == '.' and visited[temp_h][temp_w - 1] < 0:
                    visited[temp_h][temp_w - 1] = visited[temp_h][temp_w] + 1
                    q.put((temp_h, temp_w - 1))

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

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

def amount(num, A):
    ret = 0
    for i, a in enumerate(A):
        if (i+1) % num == 0:
            ret += a
    return ret

tmp = 0
for i in range(N-1, -1, -1):
    tmp = amount(i+1, A)
    if tmp == i:
        tmp = i
        break

print(tmp)
for i in range(1, tmp+1):
    if i % tmp == 0:
        print(i)


### FIXED CODE ###

N = int(input())
A = [0] + list(map(int, input().split()))

for i in range(N//2, 0, -1):
    # tmp = 0
    # j = i
    # while j < N+1:
    #     tmp += A[j]
    #     j += j
    # A[i] = tmp % 2
    A[i] = sum(A[i::i]) % 2
ans = [i for i, j in enumerate(A) if j == 1]

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

n,m = map(int,input().split())
p = {str(i):[] for i in range(1,n+1)}
l = []
for i in range(m):
    t = input().split()
    l.append((t[0],int(t[1])))
    p[t[0]].append(int(t[1]))
for i in range(1,n+1):
    p[str(i)].sort()
for t in l:
    print(t[0].zfill(6)+str(p[t[0]].index(t[1])+1).zfill(6))

### FIXED CODE ###

n,m = map(int,input().split())
p = {str(i):[] for i in range(1,n+1)}
l = []
for i in range(m):
    t = input().split()
    l.append((t[0],int(t[1])))
    p[t[0]].append(int(t[1]))
for i in range(1,n+1):
    i = str(i)
    p[i].sort()
    d = {}
    for j in range(len(p[i])):
        d[p[i][j]] = str(i).zfill(6)+str(j+1).zfill(6)
    p[i]=d
for t in l:
    print(p[t[0]][t[1]])
### BUGGY CODE ###

N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [100010]*N
dps = set()
dp[0] = 0
if K>N:
    print(h[N-1]-h[0])
    exit()
for i in range(1,N):
    for j in range(1,K+1):
        dps.add(dp[i-j]+abs(h[i]-h[i-j]))
    dp[i] = min(dps)
    dps.clear()
print(dp[N-1])

### FIXED CODE ###

import numpy as np
N,K = map(int,input().split())
h = np.array(list(map(int,input().split())))
dp = np.zeros(N, dtype=int)
for i in range(1,N):
    start = max(0,i-K)
    dp[i] = np.min(dp[start:i]+np.abs(h[i]-h[start:i]))
print(dp[N-1])
### BUGGY CODE ###

import numpy as np
N=int(input())
AN=map(int, input().split())
BN=[0 for i in range(N)]
for i in AN:
    BN[i-1] += 1
BN=[i for i in BN if i > 0]
BN.sort(reverse=True)

for K in range(1, N+1):
    x = np.zeros(K)
    for i in BN:
        x[x.argmin()] += i

    print (int(x.min()))


### FIXED CODE ###

N=int(raw_input())
AN=map(int, raw_input().split())

BN=[0 for i in xrange(N)]
for i in AN:
    BN[i-1] += 1
BN.sort()

LN = [0 for i in xrange(N)]
s = 0
j = 0
try:
    for X in xrange(1, N+1):
        while j<N and  BN[j] < X:
            s += BN[j]
            j += 1
        LN[X-1] = (s + X*(N - j)) / X
except IndexError:
    pass

KN = [0 for i in xrange(N)]
for i in xrange(len(LN)):
    KN[LN[i]-1] = i+1

for i in xrange(len(KN)-2, -1, -1):
    if KN[i] == 0:
        KN[i] = KN[i+1]

for i in KN:
    print (str(i))
### BUGGY CODE ###

from collections import deque
S=input()
Q=int(input())

deq=deque()
for s in S:
    deq.append(s)
rev=False

for _ in range(Q):
    query=input().split()
    if query[0]=="1":
        rev = not rev
    else:
        if rev:
            query[1]=str(3-int(query[1]))
        if query[1]=="1":
            deq.appendleft(query[2])
        else:
            deq.append(query[2])

if rev:
    deq.reverse()
ans=""
for i in range(len(deq)):
    ans+=deq[i]
print(ans)

### FIXED CODE ###

S=input()
Q=int(input())

# deq=deque()
# for s in S:
#     deq.append(s)

rev=False
front=""
last=""
# ans+=S

for _ in range(Q):
    query=input().split()
    if query[0]=="1":
        rev = not rev
        # print(rev)
    else:
        if rev:
            query[1]=str(3-int(query[1]))
        if query[1]=="1":
            # deq.appendleft(query[2])
            front=query[2]+front
        else:
            # deq.append(query[2])
            last+=query[2]

# if rev:
#     deq.reverse()
# # ans=""
# for i in range(len(deq)):
#     ans+=deq[i]

if not rev:
    print(front+S+last)
else:
    print(last[::-1]+S[::-1]+front[::-1])
### BUGGY CODE ###

A, B, K = map(int, input().split())

for i in range(K):
    if A > 0:
        A -= 1
    elif A == 0 and B > 0:
        B -= 1
    elif A == B == 0:
        pass

print(A, B)
        
        

### FIXED CODE ###

A, B, K = map(int, input().split())

if A >= K:
    A -= K
elif A < K < A + B:
    B -= K - A
    A = 0
elif A + B <= K:
    A = B = 0
    
print(A, B)
### BUGGY CODE ###

import numpy as np

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


MOD = 1000000007
numbers = S[:]
numbers.sort()


dp = np.zeros((N+1, X+1), dtype=int)
dp = np.arange(X+1)
dp_n = []
i = 0
for n  in numbers:
    dp_n = np.zeros((X+1), dtype=np.int64)
    dp_n += [dp[x % n] for x in range(X+1)]
    dp_n = dp_n % MOD
    dp_n += dp * i % MOD
    dp_n = dp_n % MOD
    dp = dp_n
    i += 1

print(int(dp_n[X]) % MOD)


### FIXED CODE ###

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

MOD = 1000000007
numbers = S[:]
numbers.sort(reverse=True)


dp = {X: 1}

for i, n in enumerate(numbers):
    tmp_dp = {}
    for k, v in dp.items():
        if k < n:
            tmp_dp[k] = (tmp_dp.get(k,0)+v*(N-i))
        else:
            tmp_dp[k]=(tmp_dp.get(k,0)+v*(N-i-1)) 
            tmp_dp[k%n]=(tmp_dp.get(k%n,0)+v) 
    dp = tmp_dp.copy()
        
ans = 0
for k, v in dp.items():
    ans += k *  v

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

n = int(input())
a = list(map(int,input().split()))
a2 = list(map(lambda x:x*2,a))
All = sum(a)
t = 0
while True :
    t += 1
    if t > n :
        exit()
    print(All-sum(a2[1::2]))
    a2.append(a2[0])
    del a2[0]

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a2 = list(map(lambda x:x*2,a))
All = sum(a)
p = All-sum(a2[1::2])
a3 = [p]
for i in range(n-1) :
    p = a[i]*2 - p
    a3.append(p)
mountain = ""
for j in range(n) :
    mountain += str(a3[j])
    if j == n-1 :
        print(mountain)
        exit()
    mountain += " "
### BUGGY CODE ###

# TODO D - Cake 123
# https://atcoder.jp/contests/abc123/tasks/abc123_d

X, Y, Z, K = map(int, raw_input().split())

A = [int(x) for x in raw_input().split()]
B = [int(y) for y in raw_input().split()]
C = [int(z) for z in raw_input().split()]

AB = sorted([a+b for a in A for b in B], reverse=True)
ABC = sorted([ab + c for ab in AB[:K] for c in C], reverse=True)

for i in ABC[:K]:
    print '{}'.format(i)


### FIXED CODE ###

#abc123d
 
x,y,z,k=map(int,raw_input().split())
a=sorted(map(int,raw_input().split()),reverse=True)
b=sorted(map(int,raw_input().split()),reverse=True)
c=sorted(map(int,raw_input().split()),reverse=True)
 
ab=sorted([i+j for i in a for j in b],reverse=True)
res=sorted([ij+l for ij in ab[:k] for l in c],reverse=True)
for i in res[:k]:
	print i
### BUGGY CODE ###

X=list(input())

L=len(X)
cnt=0
i=0
while cnt<=L//2 and i<len(X)-1:
    if X[i]=="S" and X[i+1]=="T":
        X.pop(i+1)
        X.pop(i)
        cnt+=1
        i=-1
    i+=1

print(len(X))

### FIXED CODE ###

A2=list(input())
A1=[]
L=len(A2)
A1.append(A2[0])

for i in range(1,L):
    if len(A1)>=1 and A1[-1]=="S" and A2[i]=="T":
        A1.pop(-1)
    else:
        A1.append(A2[i])

print(len(A1))
### BUGGY CODE ###

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

count = 0
flag = True

while flag:
  for i in range(n):
    if a[i] %2 != 0:
      break
    else:
      a[i] = a[i]//2
    if flag == False:
      break
  count = count+1

print(count)


### FIXED CODE ###

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

count = 0
flag = True

while flag:
    for i in range(n):
        if a[i] % 2 != 0:
            flag = False

    if flag == False:
        break

    for i in range(n):
        a[i] //= 2
    count = count + 1
print(count)
### BUGGY CODE ###

S = input()
Q = int(input())

for i in range(Q):
    query = input().split()
    if query[0] == "1":
        S = S[::-1]
    else:
        f_i = int(query[1])
        c_i = query[2]
        if f_i == 1:
            S = c_i + S
        else:
            S = S + c_i
print(S)

### FIXED CODE ###

from collections import deque

S = input()
Q = int(input())
reverse_cnt = 0
s = deque([i for i in S])

for i in range(Q):
    query = input().split()
    if query[0] == "1":
        reverse_cnt += 1
    else:
        if query[1] == "1":
            if reverse_cnt % 2 == 0:
                s.appendleft(query[2])
            else:
                s.append(query[2])
        else:
            if reverse_cnt % 2 == 0:
                s.append(query[2])
            else:
                s.appendleft(query[2])

if reverse_cnt % 2 == 0:
    while s:
        print(s.popleft(), end="")
else:
     while s:
        print(s.pop(), end="")
### BUGGY CODE ###

import copy
n = int(input())
num = list(map(int,input().split()))

end = n
i = 0
while i < end-1:
    for j in range(end-1, i, -1):
        if num[j] > num [i]:
            num.pop(j)
    end = len(num)
    i += 1
    
print(end)

### FIXED CODE ###

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

now = num[0]
cnt = 1
for i in range(1,n):
    if (now > num[i]):
        cnt+=1
        now = num[i]
    
print(cnt)
### BUGGY CODE ###

from functools import reduce

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

cnt = 0
l = 0
r = 1
for l in range(N):
    r = l+1
    b = A[l]
    t = 0
    while sum(A[l:r]) == reduce(lambda a, b: a^b, A[l:r]) and r < N+1:
        r += 1
        cnt += 1
print(cnt)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
cnt = 0
t = 0
r = 0
for l in range(N):
    while r < N and (t & A[r]) == 0:
        t += A[r]
        r += 1
    t -= A[l]
    cnt += (r-l)

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

import bisect
n = int(input())
a = [int(item) for item in input().split()]
cnt = [0] * (n + 1)
for item in a:
    cnt[item] += 1
cnt.sort()
cumsum = [0] * (n + 2)
for i in range(n+1):
    cumsum[i+1] = cumsum[i] + cnt[i]

ans = []
for i in range(n):
    if cnt[i+1] == 0:
        ans.append(0)
        continue
    l = 0; r = n+1
    while r - l > 1:
        mid = (l + r) // 2
        index = bisect.bisect_left(cnt, mid) - 1
        if index <= i:
            l = mid
            continue
        num = index - i
        if mid * num <= cumsum[index + 1]:
            l = mid
        else:
            r = mid
    ans.append(l)

ans.reverse()
for item in ans:
    print(item)

### FIXED CODE ###

import bisect
import sys
input = sys.stdin.readline

n = int(input())
a = [int(item) for item in input().split()]
cnt = [0] * (n + 1)
for item in a:
    cnt[item] += 1
cnt.sort()
cumsum = [0] * (n + 2)
for i in range(n+1):
    cumsum[i+1] = cumsum[i] + cnt[i]

indexes = [0] * (n+1)
for i in range(n+1):
    indexes[i] = bisect.bisect_left(cnt, i) - 1

ans = []
for i in range(n):
    if cnt[i+1] == 0:
        ans.append(0)
        continue
    l = 0; r = n+1
    while r - l > 1:
        mid = (l + r) // 2
        index = indexes[mid]
        if index <= i:
            l = mid
            continue
        num = index - i
        if mid * num <= cumsum[index + 1]:
            l = mid
        else:
            r = mid
    ans.append(l)

ans.reverse()
print("\n".join([str(item) for item in ans]))
### BUGGY CODE ###

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

#出現するアルファベットをカウントしていく
al_list=[chr(ord('a') + i) for i in range(26)]

num_list = []
for _s in s_list:
    num = ''
    for _al in al_list:
        num += str(_s.count(_al))
    num_list.append(num)

count_list = []
for _num in num_list:
    count = num_list.count(_num)
    count_list.append(count)

ans = 0
for i in range(1,n+1):
    ans += count_list.count(i) * (i - 1) / 2

print(int(ans))





### FIXED CODE ###

from collections import Counter #ハッシュ法
N = int(input())
s_list = [input() for i in range(N)]

#出現するアルファベットをカウントしていく
al_list = [chr(ord('a') + i) for i in range(26)]

num_list = []
count_by_kw = Counter()
for _s in s_list:
    num = ''
    for _al in al_list:
        num += str(_s.count(_al))
    
    num_list.append(num)

count_list = list(Counter(num_list).values()) 

ans = 0
for i in range(len(count_list)):
    k = count_list[i]
    ans += k * (k - 1) / 2

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

#!/usr/bin/python3
from operator import attrgetter
import sys
class Point:
    pass

class Node:
    pass

def kdtree(points, depth=0):
    if not points:
        return
    # dimension
    if depth % 2 == 0:
        points.sort(key=attrgetter('x'))
    else:
        points.sort(key=attrgetter('y'))

    median = len(points)//2

    node = Node()
    node.location = points[median]
    node.left = kdtree(points[:median], depth + 1)
    node.right = kdtree(points[median + 1:], depth + 1)
    return node

def find(sx, tx, sy, ty, node, depth, result):
    if node == None:
        return
    if sx <= node.location.x <= tx and sy <= node.location.y <= ty:
        result.append(node.location.id)

    if depth % 2 == 0:
        if sx <= node.location.x:
            find(sx, tx, sy, ty, node.left, depth + 1, result)
        if node.location.x <= tx:
            find(sx, tx, sy, ty, node.right, depth + 1, result)
    else:
        if sy <= node.location.y:
            find(sx, tx, sy, ty, node.left, depth + 1, result)
        if node.location.y <= ty:
            find(sx, tx, sy, ty, node.right, depth + 1, result)

# main
n = int(input())
points = []
for i in range(n):
    point = Point()
    point.id = i
    point.x, point.y = map(int, sys.stdin.readline().split())
    points.append(point)
tree = kdtree(points)
q = int(input())
for i in range(q):
    sx, tx, sy, ty = map(int, sys.stdin.readline().split())
    result = []
    find(sx, tx, sy, ty, tree, 0, result)
    result.sort()
    for r in result:
        print(r)
    print()

### FIXED CODE ###

#!/usr/bin/python3
from sys import stdin
import math
from operator import itemgetter
from bisect import bisect_left, bisect_right
readline = stdin.readline

def main():
    n = int(readline())
    xy = [tuple(map(int, readline().split())) + (i,) for i in range(n)]
    # [..., (x_i, y_i, i), ...]
    # sort by x
    xy.sort()

    root = int(math.sqrt(len(xy)))

    low = [x for x, y, i in xy[::root]]
    high = [x for x, y, i in xy[root - 1::root]] + [float('inf')]

    xy = [sorted(xy[i:i + root], key=itemgetter(1)) for i in range(0, len(xy), root)]
    xy = [([y for x, y, i in xyi], xyi) for xyi in xy]
    for sx, tx, sy, ty in (map(int, readline().split()) for _ in range(int(readline()))):
        ret = []
        for i in range(bisect_left(high, sx), bisect_right(low, tx)):
            k, v = xy[i]
            for i in range(bisect_left(k, sy), bisect_right(k, ty)):
                if sx <= v[i][0] <=tx:
                    ret.append(v[i][2])
        if ret:
            ret.sort()
            print('\n'.join(map(str,ret)))
        print()

main()
### BUGGY CODE ###

import math
x = int(input())
b = 0

def calc(b, b5):
    a = (x+b5)**0.2

    if a.real.is_integer():
        print(int(a), b)
        exit()

while True:
    b5 = b ** 5
    calc(b, b5)
    if x-b5 >= 0:
        calc(-b, -b5)
    b += 1


### FIXED CODE ###

import math
x = int(input())
b = 0

"""
def calc(b, b5):
    a = (x+b5)**0.2

    if a.real.is_integer():
        print(int(a), b)
        exit()

while True:
    b5 = b ** 5
    calc(b, b5)
    if x-b5 >= 0:
        calc(-b, -b5)
    b += 1
    """

for i in range(-120,120):
    for j in range(-120,120):
        if i**5 - j**5 == x:
            print(i, j)
            exit()
### BUGGY CODE ###

a,b,k = map(int,input().split())
lia = list(range(a,a+k))
lib = list(range(b-k+1,b+1))
setans = set(lia + lib)&set(range(a,b+1))
for i in sorted(setans):
  print(i)

### FIXED CODE ###

a,b,k = map(int,input().split())
lia = list(range(a,a+k))
lib = list(range(b-k+1,b+1))
if a+k > b:
  setans = set(lia + lib)&set(range(a,b+1))
else:
  setans = set(lia + lib)
for i in sorted(setans):
  print(i)
### BUGGY CODE ###

N,M = map(int,input().split())
XY = [list(map(int,input().split())) for i in range(M)]
Q = [1 for i in range(N)]

dp = [[0 for i in range(N)] for i in range(M+1)] #dp[m][n]
dp[0][0]=1

for i in range(1,M+1):
  x=XY[i-1][0]
  y=XY[i-1][1]
  for j in range(N):
    dp[i][j]=dp[i-1][j]

  if dp[i-1][x-1]>=1:
    if Q[x-1]==1:
      dp[i][x-1]=0
    else:
      dp[i][x-1]=1
    dp[i][y-1]=dp[i-1][y-1]+1
  Q[x-1]-=1
  Q[y-1]+=1
  
ans=0
for i in range(N):
  if dp[M][i]>=1:
    ans+=1
print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
XY = [list(map(int,input().split())) for i in range(M)]
Q = [1 for i in range(N)]

dp = [0 for i in range(N)] #dp[m][n]
dp[0]=1

for i in range(1,M+1):
  x=XY[i-1][0]
  y=XY[i-1][1]

  if dp[x-1]>=1:
    if Q[x-1]==1:
      dp[x-1]=0
    else:
      dp[x-1]=1
    dp[y-1]+=1
  Q[x-1]-=1
  Q[y-1]+=1
  
ans=0
for i in range(N):
  if dp[i]>=1:
    ans+=1
print(ans)
### BUGGY CODE ###

from itertools import permutations
n = int(input())
v = list(map(int, input().split()))
M = 0
for i in permutations(v):
    m = i[0]
    for j in i:
        m = (m + j) / 2
    M = max(m, M)
print(M)

### FIXED CODE ###

n = int(input())
v = list(map(int, input().split()))
v.sort()
ans = v[0]
for i in range(1, n):
    ans = (ans + v[i]) / 2
print(ans)
### BUGGY CODE ###

import math
from collections import Counter

def make_divisors(n):
    divisors = []
    for i in range(1, int(math.sqrt(n))+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors


def main():
    N = int(input())
    A = list(map(int, input().split()))
    a = Counter(A)
    if a[1] > 1:
        return 0
    if a[1] == 1:
        return 1
    b = set(A)
    c = {}
    def find(x):
        if x in c:
            return c[x]
        l = make_divisors(x)
        for j in l:
            if j == x:
                if a[j] > 1:
                    c[x] = 0
                    return 0
            else:
                if j in b:
                    c[x] = 0
                    return 0
        c[x] = 1
        return 1
    r = 0
    for i in A:
        r += find(i)
    return r
print(main())



### FIXED CODE ###

#dame datta....
from collections import Counter
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = sorted(A)
    a = Counter(A)
    l = [0] * (10**6+1)
    v = [0] * (10**6+1)
    for i in B:
        if v[i] == 1 or l[i] == 1:
            continue
        else:
            v[i] = 1
        t = 2*i
        while t < 10**6 + 1:
            l[t] = 1
            t += i
    r = 0
    for i in A:
        if l[i] == 0 and a[i] == 1:
            r += 1
    return r
print(main())