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

def slove():
    import sys
    input = sys.stdin.readline
    s = [int(v) if v != "?" else -1 for v in list(str(input().rstrip('\n')))]
    dp = [[0] * 13 for _ in range(2)]
    mod = 10 ** 9 + 7
    for i in range(len(s)):
        if s[-i-1] == -1:
            for j in range(10):
                if i == 0:
                    dp[1][j % 13] += 1
                else:
                    for k in range(13):
                        dp[1][(10 ** i * j + k) % 13] += (dp[0][k] % mod)
        else:
            if i == 0:
                dp[1][s[-i-1] % 13] += 1
            else:
                for k in range(13):
                    dp[1][(10 ** i * s[-i-1] + k) % 13] += (dp[0][k] % mod)
        for j in range(13):
            dp[0][j] = dp[1][j]
            dp[1][j] = 0
    print(dp[0][5] % mod)


if __name__ == '__main__':
    slove()


### FIXED CODE ###

def slove():
    import sys
    input = sys.stdin.readline
    s = [int(v) if v != "?" else -1 for v in list(str(input().rstrip('\n')))]
    dp = [[0] * 13 for _ in range(2)]
    mod = 10 ** 9 + 7

    for i in range(1):
        if s[-i-1] == -1:
            for j in range(10):
                dp[0][j % 13] += 1
        else:
            dp[0][s[-i - 1] % 13] += 1

    for i in range(1, len(s)):
        m = pow(10, i, 13)
        if s[-i-1] == -1:
            for j in range(10):
                mj = m * j
                for k in range(13):
                    dp[1][(mj + k) % 13] += dp[0][k]
        else:
            for k in range(13):
                dp[1][(m * s[-i-1] + k) % 13] += dp[0][k]
        for j in range(13):
            dp[0][j] = dp[1][j] % mod
            dp[1][j] = 0
    print(dp[0][5] % mod)


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

def main():
    a, b, k = map(int, input().split())
    
    for x in range(a, b+1):
        if x <= a+k-1 or b-k+1 <= x:
            print(x) 
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    a, b, k = map(int, input().split())
    
    s = set()

    for i in range(a, a+k):
        s.add(i)

    for i in range(b-k+1, b+1):
        s.add(i)

    for i in sorted(s):
        if a <= i and i <= b:
            print(i)

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

import heapq
N = int(input())
a = list(map(int,input().split()))
fa = a[:N:]
ba = list(map(lambda x: x*(-1), a[2*N::]))
heapq.heapify(fa)
heapq.heapify(ba)
suml = [sum(fa)]
k = -2

for i in range(N, 2*N):
    heapq.heappush(fa, a[i])
    heapq.heappop(fa)
    suml.append(sum(fa))

suml[-1] += sum(ba)

for j in range(2*N-1, N-1, -1):
        heapq.heappush(ba, -a[j])
        heapq.heappop(ba)
        suml[k] += sum(ba)
        k -= 1
    


print(max(suml))

### FIXED CODE ###

import heapq
N = int(input())
a = list(map(int,input().split()))
fa = a[:N:]
ba = list(map(lambda x: x*(-1), a[2*N::]))
heapq.heapify(fa)
heapq.heapify(ba)
sumf = sum(fa)
sumb = sum(ba)
suml = [sumf]

k = -2

for i in range(N, 2*N):
    heapq.heappush(fa, a[i])
    sumf += a[i]
    sumf -= heapq.heappop(fa)
    suml.append(sumf)

suml[-1] += sumb

for j in range(2*N-1, N-1, -1):
        heapq.heappush(ba, -a[j])
        sumb -= a[j]
        sumb -= heapq.heappop(ba)
        suml[k] += sumb
        k -= 1
    


print(max(suml))
### BUGGY CODE ###


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

if abs(n - abs(n-k)) == 1:
    print(0)
else:
    while n > abs(n-k):
        if n > abs(n-k):
            n = abs(n-k)
    print(n)


### FIXED CODE ###

n,k = map(int,input().split())
a = n % k
if a < abs(a-k):
    print(a)
else:
    print(abs(a-k))
### BUGGY CODE ###

import sys
readline = sys.stdin.readline

N,X,Y = map(int,readline().split())

G = [[] for i in range(N)]
G[X - 1].append(Y - 1)
G[Y - 1].append(X - 1)

for i in range(N - 1):
  G[i].append(i + 1)
  G[i + 1].append(i)
  
ans = [0 for i in range(N)]

from collections import deque
for st in range(N):
  q = deque([[st,0,-1]])
  visited = set()
  while q:
    v,dist,parent = q.popleft()
    if v in visited:
      continue
    visited.add(v)
    ans[dist] += 1
    for child in G[v]:
      if child == parent:
        continue
      q.append([child, dist + 1, v])
    
for i in range(1, N):
  print(ans[i] // 2)

### FIXED CODE ###

N,X,Y=map(int,input().split())

E=[[] for i in range(N)]

for i in range(N-1):
  E[i].append(i+1)
  E[i+1].append(i)
  
E[X-1].append(Y-1)
E[Y-1].append(X-1)

INF=10**4

ans=[0 for i in range(N)]
from collections import deque
for i in range(N):
  score=[INF for i in range(N)]
  q=deque([[i,0]])
  while q:
    v,dist=q.pop()
    if score[v]>dist:
      score[v]=dist
    else:
      continue
    for child in E[v]:
      q.append([child,dist+1])
  for s in score:
    ans[s]+=1
    
for i in range(1,N):
  print(ans[i]//2)
### BUGGY CODE ###

import sys
# import pdb
input = sys.stdin.readline

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

dp_list = [-1 for _ in range(N)]
dp_list[0] = 0
dp_list[1] = abs(hs[1] - hs[0])

sys.setrecursionlimit(100000)
def dp_memo(p):
  if dp_list[p] != -1:
    return dp_list[p]

  costs = []
  if K <= p:
    for i in range(1,K+1):
        costs.append(dp_memo(p-i) + abs(hs[p] - hs[p-i]))
  else:
    for i in range(1,p+1):
        costs.append(dp_memo(p-i) + abs(hs[p] - hs[p-i]))
  result = min(costs)
  dp_list[p] = result
  return result


def dp_recur():
  cost1 = 0
  cost2 = abs(hs[1] - hs[0])

  if N == 2:
    print(cost2)
    exit()
  # pdb.set_trace()
  for i in range(2, N):
    cost3 = min(cost2 + abs(hs[i] - hs[i-1]), cost1 + abs(hs[i] - hs[i-2]))
    cost1 = cost2
    cost2 = cost3
  return cost3

# print(dp_recur())
print(dp_memo(N-1))


### FIXED CODE ###

import sys
# import pdb
input = sys.stdin.readline

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

inf = 1e10

dp_list = [inf for _ in range(N)]
dp_list[0] = 0

# import heapq

sys.setrecursionlimit(1000000)
def dp_memo(p):
  if dp_list[p] != -1:
    return dp_list[p]

  costs = []
  # heapq.heapify(costs)
  if K <= p:
    for i in range(1,K+1):
        # heapq.heappush(costs, dp_memo(p-i) + abs(hs[p] - hs[p-i]))
        costs.append(dp_memo(p-i) + abs(hs[p] - hs[p-i]))
  else:
    for i in range(1,p+1):
        # heapq.heappush(costs, dp_memo(p-i) + abs(hs[p] - hs[p-i]))
        costs.append(dp_memo(p-i) + abs(hs[p] - hs[p-i]))
  result = min(costs)
  # result = heapq.heappop(costs)
  dp_list[p] = result
  return result


def dp_recur(N):
  for i in range(1, N):
    for j in range(1,K+1):
      if i-j < 0:
        break
      dp_list[i] = min(dp_list[i], dp_list[i-j] + abs(hs[i] - hs[i-j]))
  return dp_list[N-1]

print(dp_recur(N))
# print(dp_memo(N-1))
### BUGGY CODE ###

import numpy as np
from itertools import permutations

n = int(input())
k = 0
dis = 0

li = []
for _ in range(n):
    i, j = map(int, input().split())
    li.append(np.array([i, j]))

li2 = permutations(li)

re = []
for a in li2:
    k += 1
    for (x1,y1),(x2,y2) in zip(a,a[1:]):
        dis += ((x1-x2)**2+(y1-y2)**2)**0.5

print(dis/k)

### FIXED CODE ###

import numpy as np
from itertools import permutations
from math import hypot

n = int(input())

li = []
for _ in range(n):
    i, j = map(int, input().split())
    li.append(np.array([i, j]))

li2 = permutations(li)

re = []
for a in li2:
    dis = 0 
    for (x1,y1),(x2,y2) in zip(a,a[1:]):
        dis += hypot(x1-x2, y1-y2)
    re.append(dis)

print(np.average(re))
### BUGGY CODE ###

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

ans = 0
for i in range(n-1):
    for j in range(n-1-i):
        if a[i] >= 1000000007:
            while a[i] >= 1000000007:
                a[i] = a[i] - 1000000007
            hoge = a[i] * a[i+1+j]
        elif a[i+1+j] >= 1000000007:
            while a[i+1+j] >= 1000000007:
                a[i+1+j] = a[i+1+j] - 1000000007
            hoge = a[i]*a[i+1+j]
        else:
            hoge = a[i] * a[i+1+j] % 1000000007
        while hoge >= 1000000007:
            hoge = hoge - 1000000007
        ans = ans + hoge
        if ans >= 1000000007:
            ans = ans - 1000000007
print(ans)

### FIXED CODE ###

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

s = sum(a)
ans = 0
mod = 10 ** 9 + 7

for i in range(n-1):
    s -= a[i]
    ans += a[i] * s % mod

ans = ans % mod
print(ans)
### BUGGY CODE ###

n = int(input())
s = list(input())
minChange = n

w = []
tempW = 0
for i in range(n):
    if s[i] == 'W':
        tempW += 1
    w.append(tempW)

e = []
tempE = 0
for i in range(n):
    if s[i] == 'E':
        tempE += 1
    e.append(tempE)

for i in range(n):
    if s[i] == 'W':
        acW = w[i] - 1
        racE = s.count('E') - e[i]
        minChange = min(minChange, acW + racE)
    else:
        acW = w[i]
        racE = s.count('E') - e[i]
        minChange = min(minChange, acW + racE)

print(minChange)


### FIXED CODE ###

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

reS = S[::-1]

wSum = [0 for i in range(N)]
eSum = [0 for i in range(N)]

for i in range(N):
    if i == 0:
        if S[i] == 'W':
            wSum[i] = 1
        if reS[i] == 'E':
            eSum[i] = 1
    else:
        if S[i] == 'W':
            wSum[i] = wSum[i-1] + 1
        else:
            wSum[i] = wSum[i-1]
        if reS[i] == 'E':
            eSum[i] = eSum[i-1] + 1
        else:
            eSum[i] = eSum[i-1]

eSum = eSum[::-1]

cost = eSum[1]

for i in range(1,N):
    if i == N - 1:
        if cost > wSum[N-2]:
            cost = wSum[N-2]
    else:
        if cost > wSum[i-1] + eSum[i+1]:
            cost = wSum[i-1] + eSum[i+1]
print(cost)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10000000)
from collections import defaultdict
from queue import deque
N,Q = map(int,input().split())

tree = defaultdict(deque)
for i in range(N-1):
    a,b = map(int,input().split())
    tree[a].append(b)
    tree[b].append(a)

adds = {}
ans = {}
for i in range(1,N+1):
    adds[i] = 0
    ans[i] = 0
for q in range(Q):
    p,x = map(int,input().split())
    adds[p] += x
# print(tree)
# print(adds)

checked = [False for _ in range(N+1)]
def dig(i,tmp):
    global checked
    tmp += adds[i]
    ans[i] = tmp
    checked[i] = True
    for v in tree[i]:
	    if not checked[v]: dig(v,tmp)

tmp = 0
dig(1,tmp)

print(' '.join(str(ans[i]) for i in range(1,N+1)))

### FIXED CODE ###

from queue import deque
N,Q = map(int,input().split())
tree = [[] for i in range(N+1)]
for i in range(N-1):
    a,b = map(int,input().split())
    tree[a].append(b)
    tree[b].append(a)

ans = {i+1:0 for i in range(N)}
for i in range(Q):
    p,x = map(int,input().split())
    ans[p] += x

checked = [False for i in range(N+1)]
myq = deque()
myq.append(1)

while myq:
    v = myq.pop()
    checked[v] = True
    for n in tree[v]:
        if not checked[n]:
            ans[n] += ans[v]
            myq.append(n)
print(' '.join(str(ans[i]) for i in range(1,N+1)))
### BUGGY CODE ###

def solve(N, A, S):
    dp = set()
    dp.add(0)
    for i in reversed(range(N)):
        if S[i] == "0":
            st = set()
            for v in dp:
                st.add(v ^ A[i])
            dp |= st
        else:
            if not A[i] in dp:
                return 1
    return 0

def main():
    T = int(input())
    ans = [None]*T
    for i in range(T):
        N = int(input())
        A = list(map(int, input().split()))
        S = input()
        if S[-1] == "1":
            ans[i] = 1
        else:
            ans[i] = solve(N, A, S)
    for v in ans:
        print(v)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def solve(N, A, S):
    dp = []
    for i in reversed(range(N)):
        x = A[i]
        for v in dp:
            x = min(x, v^x)
        if x > 0:
            if S[i] == "0":
                dp.append(x)
            else:
                return 1
    return 0

def main():
    T = int(input())
    ans = [None]*T
    for i in range(T):
        N = int(input())
        A = list(map(int, input().split()))
        S = input()
        ans[i] = solve(N, A, S)
    for v in ans:
        print(v)

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

N=int(input())
A=list(map(int,input().split()))
result=A[0]
for i in range(1,N):
    result=result*A[i]
if result>10**18:
    print(-1)
else:
    print(result)


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
sorted(A)
result=1
if 0 in A:
    result=0
for i in A:
    if result==0:
        break
    result*=i
    if result>1000000000000000000:
        result=-1
        break

print(result)
### BUGGY CODE ###

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

sumA = sum(A)
ct = {0:1}

for a in A:
  nct = {}
  for k in ct:
    nct[k] = nct.get(k, 0) + ct[k]
    nct[k+a] = nct.get(k+a, 0) + ct[k]
  ct = nct

ct[0] = 0
medidx = (2**N)//2
n = 0
for i in range(sumA+1):
  n += ct.get(i, 0)
  if n >= medidx:
    print(i)
    exit()

### FIXED CODE ###

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

sumA = sum(A)
halfA = math.ceil(sumA / 2)
bitset = 1
for a in A:
  bitset |= bitset << a

bitset >>= halfA
i = 0
while i < halfA:
  if bitset & 1:
    print(i+halfA)
    exit()
  bitset >>= 1
  i += 1
print(i+halfA)
### BUGGY CODE ###

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

p = [(x + 1) / 2 for x in p]

ans = 0
for i in range(N - K + 1):
    ans = max(ans, sum(p[i:i+K]))

print(ans)

### FIXED CODE ###

import numpy as np
from decimal import Decimal

N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))

if N==1:
    print((p.max() + 1) / Decimal(2))
elif N==K:
    print((p.sum() + K) / Decimal(2))
else:
    p = np.cumsum(p)

    ans = []
    for i in range(N - K):
        ans.append(p[i + K]-p[i])

    ans = (max(ans) + K) / Decimal(2)

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

# C
from collections import Counter
 
def ana(a,b):
    if sorted(a) == sorted(b): return 1
    return 0
    
n = int(input())
s = []
for i in range(n): s.append(input()) 

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


### FIXED CODE ###

# C
from collections import *

n = int(input())
dic = defaultdict(lambda: 0)
for i in range(n): dic["".join(sorted(input()))] += 1

ans = 0
for k,v in dic.items(): ans += v*(v-1)//2
print(ans)
### BUGGY CODE ###

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

n = int(input())
A = list(map(int, input().split()))
edges = [[]for _ in range(n)]
for _ in range(n-1):
    u, v = list(map(lambda x: int(x)-1, input().split()))
    edges[u].append(v)
    edges[v].append(u)
INF = 10**18
ans = [INF]*n


def dfs(v, parent, lis):
    x = bisect.bisect_left(lis, A[v])
    lis[x] = A[v]
    ans[v] = bisect.bisect_left(lis, INF)
    for v2 in edges[v]:
        if v2 == parent:
            continue
        dfs(v2, v, lis.copy())


dfs(0, -1, [INF]*n)
for x in ans:
    print(x)

### FIXED CODE ###

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


n = int(input())
A = list(map(int, input().split()))
edges = [[]for _ in range(n)]
for _ in range(n-1):
    u, v = list(map(lambda x: int(x)-1, input().split()))
    edges[u].append(v)
    edges[v].append(u)
INF = 10**18
ans = [INF]*n

def dfs(v, parent):
    x = bisect.bisect_left(lis, A[v])
    prev = lis[x]
    lis[x] = A[v]
    ans[v] = bisect.bisect_left(lis, INF)
    for v2 in edges[v]:
        if v2 == parent:
            continue
        dfs(v2, v)
    lis[x] = prev


lis = [INF]*n
dfs(0, -1)
for x in ans:
    print(x)
### BUGGY CODE ###

texts = str(input())
Q = int(input())


reverse = False
start_text = ''
end_text = ''
for _ in range(Q):
    input_text = list(input().split())
    if len(input_text) == 1:
        if reverse:
            reverse = False
        else:
            reverse = True
    else:
        if input_text[1] == '1':  # 先頭に
            if reverse:
                end_text += str(input_text[2])
            else:
                start_text = str(input_text[2]) + start_text
        else:  # 末尾に
            if reverse:
                start_text = str(input_text[2]) + start_text
            else:
                end_text += str(input_text[2])

if reverse:
    text = ''.join(texts)
    text = start_text + text + end_text
    text = list(text)[::-1]
    print(''.join(text))
else:
    text = ''.join(texts)
    text = start_text + text + end_text
    print(text)


### FIXED CODE ###

from collections import deque
texts = deque(str(input()))
Q = int(input())


reverse = False
start_text = deque('')
end_text = deque('')
input_texts = []
for _ in range(Q):
    input_texts.append(list(input().split()))

for input_text in input_texts:
    if len(input_text) == 1:
        if reverse:
            reverse = False
        else:
            reverse = True
    else:
        if input_text[1] == '1':  # 先頭に
            if reverse:
                end_text.append(str(input_text[2]))
            else:
                start_text.appendleft(str(input_text[2]))
        else:  # 末尾に
            if reverse:
                start_text.appendleft(input_text[2])
            else:
                end_text.append(input_text[2])

# print(start_text, texts, end_text)
# print(''.join(texts))

texts.appendleft(''.join(start_text))
texts.append(''.join(end_text))
# print(''.join(texts))

# print(texts)
if reverse:
    texts = deque("".join(texts))
    texts.reverse()
    print("".join(texts))
else:
    # texts = start_text + texts + end_text
    print(''.join(texts))
### BUGGY CODE ###

N = int(input())
an = list(map(int, input().split()))
ans = 0
for i in range(min(an), max(an)+1):
    ans = max(ans, an.count(i) + an.count(i-1) + an.count(i+1))
print(ans)

### FIXED CODE ###

from collections import Counter
N = int(input())
an = list(map(int, input().split()))
ans = 0
cnts = Counter(an)
for i in set(an):
    ans = max(ans, cnts[i] + cnts[i+1] + cnts[i-1])
print(ans)
### BUGGY CODE ###

import math
from functools import reduce

k = int(input())
a = 0

for i in range(1, k + 1):
    for l in range(1, k + 1):
        for m in range(1, k + 1):
            a += reduce(math.gcd, [i, l, m])
print(a)


### FIXED CODE ###

import math
from functools import reduce

k = int(input())
a = 0

for i in range(1, k + 1):
    for l in range(1, k + 1):
        for m in range(1, k + 1):
            a += reduce(math.gcd, [i, l, m])
print(a)
### BUGGY CODE ###

from collections import deque
from sys import stdin
def create_groups(n, links):
  from builtins import len, set
  group_set = {}
  groups = [-1 for _ in range(n)]
  group_number = 0
  d = deque()
  for i in range(n):
    if groups[i] == -1:
      group_member = []
      d.append(i)
      while len(d) != 0:
        j = d.popleft()
        groups[j] = group_number
        group_member.append(j)
        for k in links[j]:
          if groups[k] == -1:
            d.append(k)
      group_set[group_number] = set(group_member)
      group_number += 1
  return groups, group_set
def read_links(n, k):
  from builtins import int, map
  readline = stdin.readline
  links = [[] for _ in range(n)]
  for i in range(k):
    p, q = map(int, readline().split())
    links[p - 1].append(q - 1)
    links[q - 1].append(p - 1)
  return links
cache = {}
def intersection_count(i, road_set, road_groups, train_set, train_groups):
  j = road_groups[i]
  k = train_groups[i]
  if (j, k) in cache:
    return cache[(j, k)]
  cache[(j, k)] = len(road_set[j] & train_set[k])
  return cache[(j, k)]
def main():
  from builtins import len
  n, k, l = map(int, input().split())
  road_links = read_links(n, k)
  train_links = read_links(n, l)
  road_groups, road_set = create_groups(n, road_links)
  train_groups, train_set = create_groups(n, train_links)
  print(*[intersection_count(i, road_set, road_groups, train_set, train_groups) for i in range(n)])
main()


### FIXED CODE ###

from sys import stdin

def find(parent, i):
  if parent[i] == i:
    return i
  parent[i] = find(parent, parent[i])
  return parent[i]

def unite(parent, i, j):
  i = find(parent, i)
  j = find(parent, j)
  if i == j:
    return
  parent[i] = j

n, k, l = map(int, stdin.readline().split())

roads = list(range(n))
rails = list(range(n))

for i in range(k):
  p, q = map(int, stdin.readline().split())
  unite(roads, p - 1, q - 1)

for i in range(l):
  p, q = map(int, stdin.readline().split())
  unite(rails, p - 1, q - 1)

d = {}
for i in range(n):
  t = (find(roads, i), find(rails, i))
  if t in d:
    d[t] += 1
  else:
    d[t] = 1

print(*[d[(find(roads, i), find(rails, i))] for i in range(n)])
### BUGGY CODE ###

from collections import deque

class MyClass():    
    def load(self):
        self.n = input()
        self.A = map(int,raw_input().split())
        self.q = input()
        self.M = map(int,raw_input().split())

    def main(self):
        self.load()
        W = map(self.solve,self.M)
        for w in W:
            print w

    def solve(self,m):
        qA = deque(self.A)
        for j in range(self.n):
            w = self.rec(m,qA)
            if w:
                break
            qA.popleft()            
        if w:
            return "yes"
        else:
            return "no"

    def rec(self,m,A):
        Ac = deque(list(A))
        Ad = deque(list(A))
        m_new = m
        if m_new == 0:
            r1 = True
        elif m_new < 0:
            r1 = False
        else:
            if len(A) == 1:
                r1 = False
            else:
                Ac.popleft()
                r1 = self.rec(m_new,Ac)
        m_new = m - Ad[0]
        if m_new == 0:
            r2 = True
        elif m_new < 0:
            r2 = False
        else:
            if len(A) == 1:
                r2 = False
            else:
                Ad.popleft()
                r2 = self.rec(m_new,Ad)
        if r1 or r2:
            return True
        else:
            return False

if __name__ == "__main__":
    MC = MyClass()
    MC.main()

### FIXED CODE ###

from collections import deque

def main():
    n = input()
    A = deque(map(int,raw_input().split()))
    q = input()
    M = map(int,raw_input().split())

    p = rec([0],A)

    for m in M:
        if m in p:
            print "yes"
        else:
            print "no"

def rec(a,A):
    if len(A) == 0:
        return a
    else:
        y = A.popleft()
        a = a+[x+y for x in a]
        return rec(a,A)

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

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

ans = 0

for i in range(n):
    for j in range(n):
        if i == j:
            continue
        if A[i] % A[j] == 0:
            break
    else:
        ans += 1

print(ans)



### FIXED CODE ###

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

dp = [0] * (10**6+1)

for a in A:
    dp[a] += 1

for i in range(1, len(dp)):
    if dp[i]:
        for j in range(i+i, len(dp), i):
            dp[j] = 0
print(dp.count(1))
### BUGGY CODE ###

import sys,queue,math
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in input().split()]
_LI = lambda : [int(x)-1 for x in input().split()]

N,M = LI()
B = [_LI() for _ in range(M)]

g = [i for i in range(N)]
c = [1 for _ in range(N)]

def root(x):
    if x != g[x]: g[x] = root(g[x])
    return g[x]

def union(x,y):
    rx = root(x)
    ry = root(y)
    if rx != ry:
        g[ry] = rx
        c[rx] += c[ry]
        c[ry] = 0

ans = []
B.reverse()
for a,b in B:
    ra = root(a)
    rb = root(b)
    if ra == rb:
        ans.append(0)
    else:
        ans.append(c[ra]*c[rb])
        union(ra,rb)

ans.reverse()
x = 0
for a in ans:
    x += a
    print (x)

### FIXED CODE ###

import sys,queue,math
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in input().split()]
_LI = lambda : [int(x)-1 for x in input().split()]

N,M = LI()
B = [_LI() for _ in range(M)]

g = [i for i in range(N)]
c = [1 for _ in range(N)]

def root(x):
    if x != g[x]: g[x] = root(g[x])
    return g[x]

def union(x,y):
    rx = root(x)
    ry = root(y)
    if rx != ry:
        if c[ry] > c[rx]: ry,rx = rx,ry
        g[ry] = rx
        c[rx] += c[ry]
        c[ry] = 0

ans = []
B.reverse()
for a,b in B:
    ra = root(a)
    rb = root(b)
    if ra == rb:
        ans.append(0)
    else:
        ans.append(c[ra]*c[rb])
        union(ra,rb)

ans.reverse()
x = 0
for a in ans:
    x += a
    print (x)