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

S = input()
dp = [[1, 0, 0, 0]]
for s in S:
    tmp = [0, 0, 0, 0]
    if s == 'A' or s == '?':
        tmp[0] += dp[-1][0]
        tmp[1] += dp[-1][1]
        tmp[2] += dp[-1][2]
        tmp[3] += dp[-1][3]
        tmp[1] += dp[-1][0]
    if s == 'B' or s == '?':
        tmp[0] += dp[-1][0]
        tmp[1] += dp[-1][1]
        tmp[2] += dp[-1][2]
        tmp[3] += dp[-1][3]
        tmp[2] += dp[-1][1]
    if s == 'C' or s == '?':
        tmp[0] += dp[-1][0]
        tmp[1] += dp[-1][1]
        tmp[2] += dp[-1][2]
        tmp[3] += dp[-1][3]
        tmp[3] += dp[-1][2]
    dp.append(tmp)
print(dp[-1][-1]%(10**9+7))

### FIXED CODE ###

def main():
    S = input()
    mod = 10**9+7
    dp0 = 1
    dp1 = 0
    dp2 = 0
    dp3 = 0

    for s in S:
        tmp0 = dp0
        tmp1 = dp1
        tmp2 = dp2
        tmp3 = dp3

        if s == '?':
            tmp0 += 2*dp0 % mod
            tmp1 += (2*dp1 + dp0) % mod
            tmp2 += (2*dp2 + dp1) % mod
            tmp3 += (2*dp3 + dp2) % mod
        elif s == 'A':
            tmp1 += dp0 % mod
        elif s == 'B':
            tmp2 += dp1 % mod
        elif s == 'C':
            tmp3 += dp2 % mod
        dp0 = tmp0
        dp1 = tmp1
        dp2 = tmp2
        dp3 = tmp3

    print(dp3%(mod))
if __name__ == '__main__':
    main()
### BUGGY CODE ###

A, B, K = map(int, input().split())
for i in range(A,B+1):
    if A <=i < A+K or B-K < i <= B:
        print(i)

### FIXED CODE ###

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

for i in range(A, min(A+K, B+1)):
    s.add(i)
for i in range(max(B-K+1,A), B+1):
    s.add(i)
S=list(sorted(s))
for i in range(len(S)):
    print(S[i])
### BUGGY CODE ###

n , m = map(int,input().split())

hyoukou = list(map(int,input().split()))

roadssta = []
roadsfin = []

for i in range(m):
    base = input().split()
    roadssta.append(int(base[0]))
    roadsfin.append(int(base[1]))

roadssta = tuple(roadssta)

roadsfin = tuple(roadsfin)


ans = 0

ten = 1

for i in hyoukou:

    if ten not in roadssta and ten not in roadsfin:
        ans += 1
        ten += 1
        continue
    
    else:
        access = [0]
        stacnt = 0
        fincnt = 0
        
        if ten in roadssta:
            for s in roadssta:
                if s == ten:
                    access.append(hyoukou[roadsfin[stacnt]-1])
                    stacnt += 1
                else:
                    stacnt += 1
        
        if ten in roadsfin:
            for k in roadsfin:
                if k == ten:
                    access.append(hyoukou[roadssta[fincnt]-1])
                    fincnt += 1
                else:
                    fincnt += 1

        if i>max(access):
            ans += 1
            ten += 1
        else:
            ten += 1

print(ans)

### FIXED CODE ###

n , m = map(int,input().split())

hyoukou = list(map(int,input().split()))

roadssta = []
roadsfin = []

ten = [1]*n

for i in range(m):
    base = input().split()
    a = int(base[0])
    b = int(base[1])
    if hyoukou[a-1]>hyoukou[b-1]:
        ten[b-1] = 0
    elif hyoukou[a-1]<hyoukou[b-1]:
        ten[a-1] = 0
    else:
        ten[a-1] = 0
        ten[b-1] = 0

print(ten.count(1))
### BUGGY CODE ###

def intersect_list(lst1, lst2):
    arr = []
    lst = lst1.copy()
    for element in lst2:
        try:
            lst.remove(element)
        except ValueError:
            pass
        else:
            arr.append(element)
    return arr


N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))



li = intersect_list(D,T)

T.sort()
li.sort()
if T == li:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

from collections import Counter

N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

D = Counter(D)
T = Counter(T)

for i in T:
    D_count = D[i]
    T_count = T[i]
    if T_count > D_count:
        print("NO")
        exit()
print("YES")
### BUGGY CODE ###

N = int(input())
A_list = list(map(int, input().split()))
ans = 10000000000
cum_sum1 = []
cum_sum2 = []
for i in range(N-1):
    cum_sum1.append(sum(A_list[0:i+1]))
    cum_sum2.append(sum(A_list[i+1:N]))
for i in range(len(cum_sum2)):
    tmp = abs(cum_sum2[i]-cum_sum1[i])
    if tmp < ans:
        ans = tmp
print(ans)

### FIXED CODE ###

N = int(input())
A_list = list(map(int, input().split()))
ans = 10000000000
cum_sum1 = 0
cum_sum2 = sum(A_list)
for i in range(N-1):
    cum_sum1 += A_list[i]
    cum_sum2 -= A_list[i]
    tmp = abs(cum_sum1-cum_sum2)
    if tmp < ans:
        ans = tmp
print(ans)
### BUGGY CODE ###

def main():
    n = input()
    aa = []
    for _ in xrange(n):
        aa.append(input())
    bb = sorted(aa)
    b0, b1 = bb[-1], bb[-2]
    for a in aa:
        if a < b0:
            print b0
        else:
            print b1


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = input()
    aa = []
    for _ in xrange(n):
        aa.append(input())
    bb = sorted(aa)
    b0, b1 = bb[-1], bb[-2]
    for a in aa:
        if a < b0:
            print b0
        else:
            print b1
 
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

def main():
    n, m = list(map(int, input().split()))
    hList = list(map(int, input().split()))
    ABList = [list(map(int, input().split())) for _ in range(m)]
    hRelations = [[0 for _ in range(n)] for _ in range(n)]
    for a, b in ABList:
        if hList[a-1] >= hList[b-1]:
            hRelations[b-1][a-1] = 1
        if hList[b-1] >= hList[a-1]:
            hRelations[a-1][b-1] = 1
    total = 0
    for hRelation in hRelations:
        if hRelation.count(1) == 0:
            total += 1
    print(total)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from sys import stdin
import numpy as np


def main():
    n, m = list(map(int, stdin.readline().split()))
    hList = list(map(int, stdin.readline().split()))
    ABList = [list(map(int, stdin.readline().split())) for _ in range(m)]
    maxHeights = np.zeros(n)
    for a, b in ABList:
        if hList[a-1] >= maxHeights[b-1]:
            maxHeights[b-1] = hList[a-1]
        if hList[b-1] >= maxHeights[a-1]:
            maxHeights[a-1] = hList[b-1]
    total = 0
    i = 0
    for maxHeight in maxHeights:
        if maxHeight < hList[i]:
            total += 1
        i += 1
    print(total)


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

n = int(input())
a = list(map(int, input().split()))
c = 0
for i in range(0,n-1):
  for j in range(i+1,n):
    c += (a[i]%(10**9+7))*(a[j]%(10**9+7))%(10**9+7)
    c %= (10**9+7)
print(c)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
left = 0
right = 0
for i in range(n):
  left += a[i]
  left %= (10**9+7)
for j in range(n):
  right += a[j]
  right %= (10**9+7)
c = (left*right)%(10**9+7)
l = [(k**2)%(10**9+7) for k in a]
print(((c+(10**9+7)-sum(l)%(10**9+7))*pow(2, 10**9+5, 10**9+7))%(10**9+7))
### BUGGY CODE ###

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

count = 0

for r in range(0, N//R+1):    
    for g in range(0, N//G+1):
        # compute b
        b = (N - r*R - g*G) / B
        
        # judge
        if b.is_integer() and b>=0:
            count += 1

print(count)        

### FIXED CODE ###

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

count = 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:
      count += 1

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

import sys

readline = sys.stdin.readline

N = int(readline())

sqrtN = int(N ** 0.5)

i = 1
total = 0
while True:
    if N % i == 0:
        if i < (N // i) - 1:
            total += N // i - 1
        else:
            break
    i += 1

print(total)

### FIXED CODE ###

import sys

N = int(sys.stdin.readline())
i = 1
s = 0

while i ** 2 <= N:
    if N % i == 0:
        k = N // i - 1
        if k > i:
            s += k
    i += 1
print(s)
### BUGGY CODE ###

n, m = map(int, input().split())
d1 = {}
for _ in range(n):
  a, b = map(int, input().split())
  if a in d1:
    d1[a].append(b)
  else:
    d1[a] = [b]
result = 0
ct = [0] * (10 ** 4 + 1)
cc = 0
maxb = -1
for i in range(1, m + 1):
  if i in d1:
    for j in d1[i]:
      ct[j] += 1
      if j > maxb:
        maxb = j
    cc += len(d1[i])
  else:
    if cc == 0:
      continue
  result += maxb
  ct[maxb] -= 1
  cc -= 1
  if ct[maxb] == 0:
    if cc == 0:
      maxb = -1
    else:
      for j in range(maxb - 1, -1, -1):
        if ct[j] != 0:
          maxb = j
          break
print(result)


### FIXED CODE ###

n, m = map(int, input().split())
d1 = {}
for _ in range(n):
  a, b = map(int, input().split())
  if a in d1:
    d1[a].append(b)
  else:
    d1[a] = [b]
result = 0
d2 = {}
maxb = -1
for i in range(1, m + 1):
  if i in d1:
    for j in d1[i]:
      if j not in d2:
        d2[j] = 0
      d2[j] += 1
      if j > maxb:
        maxb = j
  else:
    if len(d2) == 0:
      continue
  result += maxb
  if d2[maxb] == 1:
    del d2[maxb]
    if len(d2) == 0:
      maxb = 0
    else:
      maxb = max(d2.keys())
  else:
    d2[maxb] -= 1
print(result)
### BUGGY CODE ###

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

query=[""]*Q
for i in range(Q):
    query[i]=input()

#print(query)

#Q is length
count=0
while(count<Q):
    if(count==0 or count==Q-1):
        a=query[count].split(" ")
        if(len(a)==1):
            S=S[::-1]
        else:
            if(a[1]=="1"):
                S=a[2]+S
            else:
                S+=a[2]
    else:
        a=query[count].split(" ")
        if(len(query[count+1].split(" "))==1 and len(a)==1):
            count+=2
            continue
        elif(len(a)==1):
            S=S[::-1]
        else:
            if(a[1]=="1"):
                S=a[2]+S
            else:
                S+=a[2]
    count+=1
    
print(S)


### FIXED CODE ###

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

flag=0
forward=""
back=""
for i in range(Q):
    #query[i]=input()
    b=input()

    if(len(b)==1):
        #S=S[::-1]
        flag+=1
    else:
        a=b.split(" ")
        if(flag==0):
            if(a[1]=="1"):
                #S=a[2]+S
                forward=a[2]+forward
            else:
                #S+=a[2]
                back=back+a[2]
        else:
            if(a[1]=="1"):
                #S=a[2]+S
                back=back+a[2]
            else:
                #S+=a[2]
                forward=a[2]+forward
                
    flag=flag%2

S=forward+S+back
if(flag==1):
    S=S[::-1]
print(S)
### BUGGY CODE ###

n = int(input())
p = list(map(float,input().split()))

#dp[投げたコイン枚数][表のコイン枚数] 
dp = [[0]*(n+1) for i in range(n+1)]
dp[0][0] = 1
for i in range(1,n+1):
  dp[i][0] = dp[i-1][0]*(1-p[i-1])
  dp[i][i] = dp[i-1][i-1]*p[i-1]
  for j in range(1,i):
    dp[i][j] = dp[i-1][j]*(1-p[i-1])+dp[i-1][j-1]*p[i-1]
print(sum(dp[n][(n+1)//2:]))

### FIXED CODE ###

n = int(input())
p = list(map(float,input().split()))

#dp[投げたコイン枚数][表のコイン枚数] 
dp = [[0]*(n+1) for i in range(n+1)]
dp[0][0] = 1
for i in range(1,n+1):
  dp[i][0] = dp[i-1][0]*(1-p[i-1])
  dp[i][i] = dp[i-1][i-1]*p[i-1]
  for j in range(1,i):
    dp[i][j] = dp[i-1][j]*(1-p[i-1])+dp[i-1][j-1]*p[i-1]
print(sum(dp[n][(n+1)//2:]))
### BUGGY CODE ###

n=int(input())
power=1
for i in range(1,n+1):
  power=power*i
print(power%(10**9+7))

### FIXED CODE ###

n=int(input())
power=1
for i in range(1,n+1):
  power=(power*i)%(10**9+7)
print(int(power))
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
b=set(a)
cnt=0
for i in b:
  num=a.count(i)
  if i<=num:
    cnt+=(num-i)
  else:
    cnt+=num
print(cnt)
    


### FIXED CODE ###

from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=set(a)
b=Counter(a)
cnt=0
for i in c:
  if i<=b[i]:
    cnt+=b[i]-i
  else:
    cnt+=b[i]
print(cnt)
### BUGGY CODE ###

# https://atcoder.jp/contests/abc063/submissions/5323989 参照

def func(idx, points, N, lst_s, dp):
    # base case
    if idx == N:
        if points % 10 == 0:
            return 0
        else:
            return points
    
    # check memo
    ref = dp.get((idx, points))
    if ref:
        return dp[(idx, points)]
    
    # recursive
    f1 = func(idx + 1, points, N, lst_s, dp)
    f2 = func(idx + 1, points + lst_s[idx], N, lst_s, dp)
    ret = max(f1, f2)
    dp[(idx, points)] = ret

    return ret


N = int(input())
lst_s = [int(input()) for _ in range(N)]
dp = {}
ans = func(0, 0, N, lst_s, dp)
print(ans)

### FIXED CODE ###

N = int(input())
lst_s = [int(input()) for _ in range(N)]
lst_s.sort()
max_grade = sum(lst_s)
ans = 0


if max_grade % 10 != 0:
    ans = max_grade
else:
    for s in lst_s:
        tmp_grade = max_grade - s
        if tmp_grade % 10 != 0:
            ans = max(ans, tmp_grade)

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

def solve(pos):
    start = pos
    ans = 0
    a = 0
    b = N - 1
    for i in range(N-1):
        if a==start:
            a += 1
        elif b==start:
            b -= 1
        if abs(A[a]-A[pos])>=abs(A[b]-A[pos]):
            ans += abs(A[a]-A[pos])
            pos = a
            a += 1
        else:
            ans += abs(A[b]-A[pos])
            pos = b
            b -= 1
        #print(ans, a, b)
    #print(ans)
    return ans

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

ans = 0
for pos in range(N):
    tmp = solve(pos)
    ans = max(ans, tmp)
print(ans)


### FIXED CODE ###

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

PLUS = A[int((N+1)//2):]
MINUS = A[:int((N+1)//2)]
#print(PLUS, MINUS)
ans = sum(PLUS)*2 - sum(MINUS)*2
if N%2==0:
    ans += MINUS[-1] - PLUS[0]
else:
    ans += sum(MINUS[-2:])

PLUS = A[int(N//2):]
MINUS = A[:int(N//2)]
#print(PLUS, MINUS)
ans2 = sum(PLUS)*2 - sum(MINUS)*2
if N%2==0:
    ans2 += MINUS[-1] - PLUS[0]
else:
    ans2 -= sum(PLUS[:2])

print(max(ans, ans2))
### BUGGY CODE ###

N, M = map(int, input().split())


def factorize(n):
    if n == 1:
        return [1]

    i, factors = 2, []
    while i * i <= n:
        while n % i == 0:
            n //= i
            factors.append(i)
        i += 1
    if n > 1:
        factors.append(n)
    return factors


factors = factorize(M)
n_factors = len(factors)

ans = 0
for i in range(1 << n_factors):
    x = 1
    for j in range(n_factors):
        if i & (1 << j):
            x *= factors[j]
    y = M // x
    if N <= y:
        ans = max(ans, x)
print(ans)


### FIXED CODE ###

from collections import Counter

N, M = map(int, input().split())


def factorize(n):
    if n == 1:
        return [1]

    i, factors = 2, []
    while i * i <= n:
        while n % i == 0:
            n //= i
            factors.append(i)
        i += 1
    if n > 1:
        factors.append(n)
    return factors


c = Counter(factorize(M))
a = [1]
for k, v in c.items():
    tmp = []
    for x in a:
        for i in range(v + 1):
            tmp.append(x * (k**i))
    a = list(set(a) | set(tmp))

ans = 0
for x in a:
    y = M // x
    if N <= y:
        ans = max(ans, x)
print(ans)
### BUGGY CODE ###

import sys
def input():
	return sys.stdin.buffer.readline()[:-1]
sys.setrecursionlimit(10 ** 6)

class UnionFind():
	def __init__(self, size):
		self.table = [-1 for _ in range(size)]
		self.size = [1 for _ in range(size)]

	def find(self, x):
		if self.table[x] < 0:
			return x
		else:
			self.table[x] = self.find(self.table[x])
			return self.table[x]

	def unite(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 != s2:
			if self.table[s1] > self.table[s2]:
				self.table[s2] = s1
				self.table[s1] -= 1
				self.size[s1] += self.size[s2]
				self.size[s2] = 0
			else:
				self.table[s1] = s2
				self.table[s2] -= 1
				self.size[s2] += self.size[s1]
				self.size[s1] = 0

		return

	def get_size(self, x):
		return self.size[self.find(x)]

n, m, k = map(int, input().split())
uf = UnionFind(n)

friend = [[] for _ in range(n)]
for _ in range(m):
	a, b = map(int, input().split())
	friend[a-1].append(b-1)
	friend[b-1].append(a-1)
	uf.unite(a-1, b-1)

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

ans = []
for i in range(n):
	res = uf.get_size(i) - 1 - len(friend[i])
	for v in block[i]:
		if uf.find(i) == uf.find(v):
			res -= 1
	ans.append(res)

print(*ans)

### FIXED CODE ###

import sys
def input():
	return sys.stdin.readline()[:-1]
sys.setrecursionlimit(10 ** 6)

class UnionFind():
	def __init__(self, size):
		self.table = [-1 for _ in range(size)]
		self.size = [1 for _ in range(size)]

	def find(self, x):
		if self.table[x] < 0:
			return x
		else:
			self.table[x] = self.find(self.table[x])
			return self.table[x]

	def unite(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 != s2:
			if self.table[s1] > self.table[s2]:
				self.table[s2] = s1
				self.table[s1] -= 1
				self.size[s1] += self.size[s2]
				self.size[s2] = 0
			else:
				self.table[s1] = s2
				self.table[s2] -= 1
				self.size[s2] += self.size[s1]
				self.size[s1] = 0

		return

	def get_size(self, x):
		return self.size[self.find(x)]

n, m, k = map(int, input().split())
uf = UnionFind(n)

friend = [[] for _ in range(n)]
for _ in range(m):
	a, b = map(int, input().split())
	friend[a-1].append(b-1)
	friend[b-1].append(a-1)
	uf.unite(a-1, b-1)

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

ans = []
for i in range(n):
	res = uf.get_size(i) - 1 - len(friend[i])
	for v in block[i]:
		if uf.find(i) == uf.find(v):
			res -= 1
	ans.append(res)

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

N, W = map(int, input().split())
items = [[0, 0]]
for _ in range(N):
    items.append(list(map(int, input().split())))

dp = [[float("inf") for _ in range(10 ** 5 + 1)] for _ in range(N + 1)]

for i in range(N + 1):
    dp[i][0] = 0

ans = 0
for i in range(1, N + 1):
    for j in range(10 ** 5 + 1):
        if j - items[i][1] >= 0:
            dp[i][j] = min(dp[i - 1][j - items[i][1]] + items[i][0], dp[i - 1][j])
        else:
            dp[i][j] = dp[i - 1][j]
        if dp[i][j] <= W:
            ans = max(ans, j)

print(ans)

### FIXED CODE ###

N, W = map(int, input().split())
items = [[0, 0]]
v_total = 0
for _ in range(N):
    w, v = map(int, input().split())
    items.append([w, v])
    v_total += v

dp = [[float("inf")] * (v_total + 1) for _ in range(N + 1)]

for i in range(N + 1):
    dp[i][0] = 0

ans = 0
for i in range(1, N + 1):
    for j in range(v_total + 1):
        if j - items[i][1] >= 0:
            dp[i][j] = min(dp[i - 1][j - items[i][1]] + items[i][0], dp[i - 1][j])
        else:
            dp[i][j] = dp[i - 1][j]

        if i == N and dp[i][j] <= W:
            ans = max(ans, j)

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

GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

def main():
    GI()
    CEIL = 10 ** 18

    prod = 1
    for x in GIS():
        prod *= x
    if prod > CEIL:
        prod = -1
    print(prod)

main()


### FIXED CODE ###

GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

def main():
    GI()
    CEIL = 10 ** 18

    xs = LGIS()

    prod = 1
    for x in xs:
        prod *= x
        if prod > CEIL:
            prod = -1
            break

    if prod == -1:
        print(0 if 0 in xs else -1)
    else:
        print(prod)

main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
#n = int(input())
#l = list(map(int, input().split()))
'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)'''

import sys
input = sys.stdin.readline

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

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)'''
def yakusuu(n):
    #約数リスト生成,バラバラに出るので.sort()を使う必要あるかも
    #PyPy推奨
    yakusuu_list = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            yakusuu_list.append(i)
            if i != n // i:
                yakusuu_list.append(n//i)
    return yakusuu_list

n=int(input())
a=list(map(int, input().split()))
#print(sorted(a))
a.sort()
wa=[a[0]]
waaa=[False]*(a[-1])
bl=[]

def ok(wa,waaa,item,bl):
    m=yakusuu(item)
    #print(m)
    if waaa[item-1]==True:
        bl.append(item-1)
        return

    waaa[item-1]=True

    for jtem in m:
        if jtem!=item and waaa[jtem-1]==True:
            bl.append(item-1)
            return

    waaa[item-1]=True
    #print(item,waaa[:25])
    return

for item in a:
    ok(wa,waaa,item,bl)

#import collections
print(waaa.count(True)-len(set(bl)))
#print(max(0,len(wa)-len(set(bl))))


### FIXED CODE ###

import sys
input = sys.stdin.readline

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

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''
def cal(n,li):
    lis=[True]*(n+1)
    for item in li:
        if lis[item]:
            for i in range(item*2,n+1,item):
                lis[i]=False
    return lis
from collections import Counter

n=int(input())
a=list(map(int,input().split()))
a.sort()
l=cal(a[-1],a)
ll=Counter(a)
#print(l,ll)
ans=0
for i in range(n):
    if ll[a[i]]==1:
        if l[a[i]]:
            ans+=1

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

p = int(input())
A = list(map(int, input().split()))
comb = [0]*p
comb[0] = 1
for i in range(1, p):
    comb[i] = comb[i-1] * (p-i) * pow(i, p-2, p) % p

B = [0]*p
for i in range(p):
    if A[i] == 0:
        continue
    B[0] += 1
    Pow = 1
    for j in range(p):
        B[p - 1 - j] = (B[p - 1 - j] - comb[j] * Pow) % p
        Pow = Pow * (-i) % p
print(*[b % p for b in B])

### FIXED CODE ###

p = int(input())
A = list(map(int, input().split()))
comb = [0]*p
comb[0] = 1
for i in range(1, p):
    comb[i] = comb[i-1] * (p-i) * pow(i, p-2, p) % p

B = [0]*p
for i in range(p):
    if A[i] == 0:
        continue
    B[0] += 1
    Pow = 1
    for j in range(p):
        B[p - 1 - j] = (B[p - 1 - j] - comb[j] * Pow) % p
        Pow = Pow * (-i) % p
print(*[b % p for b in B])
### BUGGY CODE ###

import sys
s= sys.stdin.readline().strip()
mod=10**9+7
n=13
dp=[0]*n
mul=1
dp[0]=1
for c in reversed(s):
  ndp=[0]*n
  if c=='?':
    for k in range(10):
      k*=mul
      for j in range(n):
        t=(k+j)%n
        ndp[t]+=dp[j]
        ndp[t]%=mod
  else:
    k=int(c)*mul
    for j in range(n):
      t=(k+j)%n
      ndp[t]+=dp[j]
      ndp[t]%=mod
  mul*=10
  mul%=n
  dp=ndp
print(dp[5])


### FIXED CODE ###

M=10**9+7
r=[[(j-k)*9%13for j in range(10)]for k in range(13)]
d=[1]+[0]*12
for c in input():
  d = [sum(d[j]for j in k)%M for k in r] if c>'9' else [d[(int(c)-k)*9%13]for k in range(13)]
print(d[5])
### BUGGY CODE ###

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

students = []

for i in range(1, N + 1):
    students.append(str(A.index(i) + 1))

print(' '.join(iter(students)))


### FIXED CODE ###

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

students = [None] * N

for i, a in enumerate(A):
    students[a - 1] = str(i + 1)

print(' '.join(iter(students)))