Harryxun/stf_run huggingface dataset:
N0 = 2**(N-1).bit_length()
INF = 2**31-1

# k番目の要素をxに更新
def update(k, x, data):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = min(data[2*k+1], data[2*k+2])

# [l,r)の最小値
def query(l, r, data):
    L = l + N0; R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, data[R-1])

        if L & 1:
            s = min(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s

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

data1 = [INF]*(2*N0)
update(0,0,data1)
for n in range(N):
    if S[n+1]=='0':
        update(n+1,query(n-M+1,n+1,data1)+1,data1)

S = S[::-1]
data2 = [INF]*(2*N0)
update(0,0,data2)
for n in range(N):
    if S[n+1]=='0':
        update(n+1,query(n-M+1,n+1,data2)+1,data2)

cost1 = [INF]*(N+1)
cost2 = [INF]*(N+1)
for n in range(N+1):
    cost1[n] = query(n,n+1,data1)
    cost2[n] = query(N-n,N-n+1,data2)

ans = []
cost = 0
for n in range(N+1):
    if cost != cost1[n] and cost1[n]+cost2[n]==cost1[N]:
        ans.append(n)
        cost = cost1[n]
ans = [0]+ans
for i in range(len(ans)-2,-1,-1):
    ans[i+1] = ans[i+1]-ans[i]

ans = ' '.join([str(c) for c in ans[1:]])
if cost2[0]==INF:
    ans = '-1'
print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
S = input()
N0 = 2**(N-1).bit_length()
INF = 2**31-1

# k番目の要素をxに更新
def update(k, x, data):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = min(data[2*k+1], data[2*k+2])

# [l,r)の最小値
def query(l, r, data):
    L = l + N0; R = r + N0
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, data[R-1])

        if L & 1:
            s = min(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s



data1 = [INF]*(3*N0)
update(0,0,data1)
for n in range(N):
    if S[n+1]=='0':
        update(n+1,query(max(0,n-M+1),n+1,data1)+1,data1)

S = S[::-1]
data2 = [INF]*(3*N0)
update(0,0,data2)
for n in range(N):
    if S[n+1]=='0':
        update(n+1,query(max(0,n-M+1),n+1,data2)+1,data2)

cost1 = [INF]*(N+1)
cost2 = [INF]*(N+1)
for n in range(N+1):
    cost1[n] = query(n,n+1,data1)
    cost2[n] = query(N-n,N-n+1,data2)

ans = []
cost = 0
for n in range(N+1):
    if cost != cost1[n] and cost1[n]+cost2[n]==cost1[N]:
        ans.append(n)
        cost = cost1[n]
ans = [0]+ans
for i in range(len(ans)-2,-1,-1):
    ans[i+1] = ans[i+1]-ans[i]

ans = ' '.join([str(c) for c in ans[1:]])
if cost2[0]==INF:
    ans = '-1'
print(ans)
n,k = map(int, input().split())
a = set()
for i in [0]*k:
    _ = input()
    a.add(*map(int, input().split()))
    print(a)
print(n - len(a))

### FIXED CODE ###

(n,k),*p = [[*map(int, i.split())] for i in open(0)]
a = sum([p[2*i+1] for i in range(k)],[])
print(n - len(set(a)))
import sys
input = sys.stdin.readline
 
n,m = map(int,input().split())
 
#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

###具体例###
for _ in range(m):
    x, y, z = [int(x) for x in input().split()]
    unite(x - 1, y - 1)

A = {}

for i in range(n):
    A.add(find(i))

print(len(A))



### FIXED CODE ###

import sys
input = sys.stdin.readline
 
n,m = map(int,input().split())
 
#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

###具体例###
for _ in range(m):
    x, y, z = [int(x) for x in input().split()]
    unite(x - 1, y - 1)

A = set()

for i in range(n):
    A.add(find(i))

print(len(A))
a,b = int(raw_input().split())
print a*b,a*2+b*2

### FIXED CODE ###

a,b = map(int,raw_input().split())
print ("{0} {1}").format(a*b,2*a+2*b)
num = int(input())
lists = [list(map(int,input().split())) for i in range(2)]
nums = [lists[0][j] - lists[1][j] for j in range(num)]
print(sorted(nums,reverse=True)[0]+sorted(nums,reverse=True)[1])

### FIXED CODE ###

num = int(input())
lists = [list(map(int,input().split())) for i in range(2)]
nums = [lists[0][j] - lists[1][j] for j in range(num)]
x = 0
for i in nums:
  if i > 0:
    x += i
  else:
    continue
print(x)
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse = True)
d = [0,2,5,5,4,5,6,3,7,6]
S = set()
for a in A:
    S.add(d[a])

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

for i in range(N+1):
    for s in S:
        if i - s >= 0:
            dp[i] = max(dp[i], dp[i-s]+1)

digit = dp[N]

def dfs(N, digit, ans):
    if digit == 0:
        if N == 0:
            return ans
        else:
            return 0
    for a in A:
        temp = dfs(N - d[a], digit - 1, ans * 10 + a)
        if temp:
            return temp

print(dfs(N, digit, 0))

### FIXED CODE ###

N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse = True)
d = [0,2,5,5,4,5,6,3,7,6]
S = set()
for a in A:
    S.add(d[a])

INF = 10 ** 8
dp = [-INF for _ in range(N+1)]
dp[0] = 0

for i in range(N+1):
    for s in S:
        if i - s >= 0:
            dp[i] = max(dp[i], dp[i-s]+1)

ans = 0
digit = dp[N]

for i in range(digit-1, -1, -1):
    if i != 0:
        for a in A:
            if dp[N-d[a]] == i:
                ans = ans * 10 + a
                N -= d[a]
                break
    else:
        for a in A:
            if N == d[a]:
                ans = ans * 10 + a
                break
print(ans)
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
diffs = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]
max_diff = 0
for diff in diffs:
    max_diff= max(max_diff, max(diff))
r_k = max_diff*(H+W)
dp = [[[False] * r_k for _ in range(W)] for _ in range(H)]
dp[0][0][0] = True
for i in range(H):
    for j in range(W):
        diff = diffs[i][j]
        for k in range(r_k):
            if dp[i][j][k] == True:
                for i_, j_ in [(i + 1, j), (i, j + 1)]:
                    for k_ in [k+diff, abs(k-diff)]:
                        try:
                            dp[i_][j_][k_] = True
                        except IndexError:
                            pass
ans = pow(80, 3)
diff = diffs[H-1][W-1]
for k in range(r_k):
    if dp[H - 1][W - 1][k]:
        ans = min(ans, abs(k-diff), k+diff)
print(ans)


### FIXED CODE ###

H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
diffs = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]
max_diff = 0
for diff in diffs:
    max_diff = max(max_diff, max(diff))
r_k = max_diff*(H+W)//2+1
dp = [[[False] * r_k for _ in range(W)] for _ in range(H)]
dp[0][0][0] = True
for i in range(H):
    for j in range(W):
        diff = diffs[i][j]
        dp_ = dp[i][j]
        if j < W-1:
            dpj = dp[i][j + 1]
            for k in range(r_k):
                if dp_[k] == True:
                    dpj[abs(k - diff)] = True
                    if k+diff<r_k:
                        dpj[k + diff] = True
        if i < H - 1:
            dpi = dp[i + 1][j]
            for k in range(r_k):
                if dp_[k] == True:
                    dpi[abs(k-diff)] = True
                    if k+diff < r_k:
                        dpi[k + diff] = True

ans = pow(80, 3)
diff = diffs[H-1][W-1]
for k, flg in enumerate(dp[H - 1][W - 1]):
    if flg:
        ans = min(ans, abs(k-diff), k+diff)
print(ans)
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N = I()
    A = LI()

    A.sort()
    divisible = set(list(range(1, 10**6+1)))

    for i in A:
        j = 1
        while i*j <= 10**6:
            if i*j in divisible:
		        divisible.remove(i*j)
                j += 1

    ans = 0
    for i in A:
        if j in divisible:
            ans += 1
        
    print(ans)

if __name__ == '__main__':
    resolve()

### FIXED CODE ###

import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N = I()
    A = LI()

    cnt = collections.Counter(A)
    A = list(set(A))
    A.sort()
    A_max = A[-1]
    divisible = [False] * (A_max + 1)

    for i in A:
        for j in range(2 * i, A_max+1, i):
            divisible[j] = True

    ans = 0
    for i in A:
        tmp = 0
        if not divisible[i] and cnt[i] == 1:
            tmp += 1
        ans += tmp

        
    print(ans)

if __name__ == '__main__':
    resolve()
while True:
    n,m=map(int,raw_input().split())
    if n==m==0:break
    S,L=set(),[]
    for i in range(m):
        a,b=map(int,raw_input().split())
        if a==1:
            S.add(b)
        elif b==1:
            S.add(a)
        else:
            L.append((a,b))
    for i in S:
        for s in L:
            if i in s:
                S=S.union(s)
    print len(S)

### FIXED CODE ###

while True:
    n=raw_input()
    if n in "0":break
    try:
        m=input()
    except SyntaxError:
        break
    S,L=set(),[]
    for i in range(m):
        a,b=map(int,raw_input().split())
        if a==1:
            S.add(b)
        elif b==1:
            S.add(a)
        else:
            L.append((a,b))
    for i in S:
        for s in L:
            if i in s:
                S=S.union(s)
    print len(S)
N=int(input())
A=list(map(int,input().split()))

ans=10**9

for i in A:
  p=0
  while i % 2 ==0:
    i=/2
    p+=1
  if p<ans:
    ans=p
    
print(ans)

### FIXED CODE ###

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

ans=10**9

for i in A:
  p=0
  while i%2 ==0:
    i/=2
    p+=1
  if p<ans:
    ans=p
    
print(ans)
a=inout().split(' ')
n=int(a[0])
sum=int(a[1])
b=999999
for i in range(n):
    c=int(input())
    if b>c:
        b=c
print(sum//b)

### FIXED CODE ###

a=input().split(' ')
n=int(a[0])
sum=int(a[1])
b=9999999
for i in range(n):
    c=int(input())
    sum-=c
    if b>c:
        b=c
print(n+sum//b)
N=int(input())
S=input()
ans=S.count("R")*S.count("G")*S.count("B")
 
for i in range(N):
  for j in range(i+1,N):
    k=j+(j-i)
    if N-1<k:
      break
 
    if S[j]!=S[i] and S[j]!=S[k] and S[k]!=S[i]:
        ans-=1
        
print(ans)

### FIXED CODE ###

from math import gcd
K=int(input())

result=[]
count=0
cnt=0
# def gcd(a,b):
#   while b!=0:
#     a,b=b,a%b
#   return a

 
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      cnt+=gcd(gcd(i,j),k)


print(cnt)
a, b = input.split()
print("H" if a == b else D"")

### FIXED CODE ###

a, b = input().split()
print("H" if a == b else "D")
import math
def main(n):
    x = 800 * n
    if n >= 15:
        y = 200 * math.floor(n / 15)
    print(x - y)

main(int(input()))

### FIXED CODE ###

import math
def main(n):
    x = 800 * n
    y = 0
    if n >= 15:
        y = 200 * math.floor(n / 15)
    print(x - y)

main(int(input()))
#制限時間以内でコストの最小のものを選ぶ
n,t=map(int,input().split())
v=[list(map(int,list(input().split()))) for i in range(n)]
list=[]
for i in range(n):
    if v[i][1] <= t:
        list.append(v[i][0])
if list==0:
    print("TLE")
else:
    print(min(list))


### FIXED CODE ###

# 制限時間以内でコストの最小のものを選ぶ
n, t = map(int, input().split())
v = [list(map(int, list(input().split()))) for i in range(n)]
list = []
for i in range(n):
    if v[i][1] <= t:
        list.append(v[i][0])
if list == []:
    print("TLE")
else:
    print(min(list))
N, X, Y = list(map(int, input().split()))
res = [0] * (n-1)
for i in range(1, N + 1):
    for j in range(1, N + 1):
        if i >= j:
            continue
        if i == X and Y == j:
            key = 1
        else:
            key = int(min(j - i, abs(X - i) + abs(Y - j) + 1))
        res[key] += 1

for i in range(1, N):
    print(res[i])


### FIXED CODE ###

N, X, Y = list(map(int, input().split()))
res = [0] * N
for i in range(1, N + 1):
    for j in range(1, N + 1):
        if i >= j:
            continue
        if i == X and Y == j:
            key = 1
        else:
            key = int(min(j - i, abs(X - i) + abs(Y - j) + 1))
        res[key] += 1

for i in range(1, N):
    print(res[i])
a, b = map(string, input().split())
ab = int(a+b)
if ab**0.5 - int(ab**0.5) == 0:
 print("Yes")
else:
 print("No")

### FIXED CODE ###

a, b = map(str, input().split())
ab = int(a+b)
if ab**0.5 - int(ab**0.5) == 0:
 print("Yes")
else:
 print("No")
def dfs(n):
    global b,check,d
    #ttfは235、chaはabc
    #2,3,5の場合それぞれ
    for ttf,cha in zip([2,3,5],b):
        #-1ずつしていく場合
        if check[0]>check[n]+n*d:
            check[0]=check[n]+n*d

        #最寄りまで-してく場合
        x1,x2=n//ttf,n%ttf
        check[x1]=-1
        if check[x1]>check[n]+x2*d+cha or check[x1]==-1:
            check[x1]=check[n]+x2*d+cha
            dfs(x1)

        #最寄りまで+1してく場合
        x1,x2=n//ttf+1,ttf-n%ttf
        check[x1]=-1
        if check[x1]>check[n]+x2*d+cha or check[x1]==-1:
            check[x1]=check[n]+x2*d+cha
            dfs(x1)

t=int(input())
for i in range(t):
    N,*b,d=map(int,input().split())
    check={N:0,0:N*d}
    dfs(N)
    print(check[0])


### FIXED CODE ###

import sys
check=dict()
N,a,b,c,d=0,0,0,0,0
#ttfは235、chaはabc
def dfs_sub(n,ttf,cha):
    global check,d
    if 0 in check:
        check[0]=min(check[n]+n*d,check[0])
    else:
        check[0]=check[n]+n*d
    if n//ttf==0:
        if n//ttf in check:
            if check[n//ttf]>check[n]+(n%ttf)*d:
                check[n//ttf]=check[n]+(n%ttf)*d
        else:
            check[n//ttf]=check[n]+(n%ttf)*d
    else:
        if n//ttf in check:
            if check[n//ttf]>check[n]+(n%ttf)*d+cha:
                check[n//ttf]=check[n]+(n%ttf)*d+cha
                dfs(n//ttf)
        else:
            check[n//ttf]=check[n]+(n%ttf)*d+cha
            dfs(n//ttf)
    if 1+n//ttf in check:
        if check[1+n//ttf]>check[n]+(ttf-n%ttf)*d+cha:
            check[1+n//ttf]=check[n]+(ttf-n%ttf)*d+cha
            dfs(1+n//ttf)
    else:
        check[1+n//ttf]=check[n]+(ttf-n%ttf)*d+cha
        dfs(1+n//ttf)


def dfs(n):
    global check,a,b,c,d
    dfs_sub(n,2,a)
    dfs_sub(n,3,b)
    dfs_sub(n,5,c)

t=int(input())
ans=[0]*t
for i in range(t):
    N,a,b,c,d=map(int,input().split())
    check={N:0}
    dfs(N)
    ans[i]=check[0]
for i in range(t):
    print(ans[i])
r, g, b = map(str, input().split())
if int(a+g+b) % 4 == 0:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

r, g, b = map(str, input().split())
if (int(r+g+b) % 4) == 0:
    print("YES")
else:
    print("NO")
import sys


def dfs(v, parent, odd):
    hi = INF
    lo = -INF
    if fixed[v] != INF:
        if odd_even[v] != odd:
            print('No')
            exit()
        hi = lo = fixed[v]
    for u in links[v]:
        if u == parent:
            continue
        chi, clo = dfs(u, v, odd ^ 1)
        if hi < clo or chi < lo:
            print('No')
            exit()
        hi = min(hi, chi)
        lo = max(lo, clo)
    upper[v] = hi
    lower[v] = lo
    return hi + 1, lo - 1


def fill(v, parent, pp):
    if pp + 1 > upper[v]:
        assert pp - 1 >= lower[v]
        vp = fixed[v] = pp - 1
    else:
        vp = fixed[v] = pp + 1
    for u in links[v]:
        if u == parent:
            continue
        fill(u, v, vp)


inp = list(map(int, sys.stdin.buffer.read().split()))
n = inp[0]
links = [set() for _ in range(n)]
for a, b in zip(inp[1:2 * n - 1:2], inp[2:2 * n - 1:2]):
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)
INF = 10 ** 9
k = inp[2 * n - 1]
fixed = [INF] * n
odd_even = {}
fixed_v = 0
for v, p in zip(inp[2 * n::2], inp[2 * n + 1::2]):
    v -= 1
    fixed[v] = p
    odd_even[v] = p % 2
    fixed_v = v

lower = [-INF] * n
upper = [INF] * n
dfs(fixed_v, -1, odd_even[fixed_v])
fill(fixed_v, -1, fixed[fixed_v] + 1)
print('Yes')
print('\n'.join(map(str, fixed)))


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 7)


def dfs(v, parent, odd):
    hi = INF
    lo = -INF
    if fixed[v] != INF:
        if odd_even[v] != odd:
            print('No')
            exit()
        hi = lo = fixed[v]
    for u in links[v]:
        if u == parent:
            continue
        chi, clo = dfs(u, v, odd ^ 1)
        if hi < clo or chi < lo:
            print('No')
            exit()
        hi = min(hi, chi)
        lo = max(lo, clo)
    upper[v] = hi
    lower[v] = lo
    return hi + 1, lo - 1


def fill(v, parent, pp):
    if pp + 1 > upper[v]:
        assert pp - 1 >= lower[v]
        vp = fixed[v] = pp - 1
    else:
        vp = fixed[v] = pp + 1
    for u in links[v]:
        if u == parent:
            continue
        fill(u, v, vp)


inp = list(map(int, sys.stdin.buffer.read().split()))
n = inp[0]
links = [set() for _ in range(n)]
for a, b in zip(inp[1:2 * n - 1:2], inp[2:2 * n - 1:2]):
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)
INF = 10 ** 9
k = inp[2 * n - 1]
fixed = [INF] * n
odd_even = {}
fixed_v = 0
for v, p in zip(inp[2 * n::2], inp[2 * n + 1::2]):
    v -= 1
    fixed[v] = p
    odd_even[v] = p % 2
    fixed_v = v

lower = [-INF] * n
upper = [INF] * n
dfs(fixed_v, -1, odd_even[fixed_v])
fill(fixed_v, -1, fixed[fixed_v] + 1)
print('Yes')
print('\n'.join(map(str, fixed)))
a, b = map(int, input())

print(a*b)


### FIXED CODE ###

a, b = map(int,input().split())
print("%d %d" %(a*b, 2*(a+b) ) )
n,a,b = map(int,input().split())
if (b-a)%2 == 0:
  print(min(b-a)//2,n-a,b-1))
else:
  print(min(n-a,b-1))

### FIXED CODE ###

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

if (b-a)%2 == 0:
    print((b-a)//2)
    exit()

print(min(b,n-a+1,a+(b-a)//2,n-b+1 + (b-a-1)//2) )
import sys
H, W, M = map(int, sys.stdin.readline().split())
hlst = [0]*(H+1)
wlst = [0]*(M+1)
hwlst = []

for i in range(M):
    h, w = map(int, sys.stdin.readline().split())
    hlst[h] += 1
    wlst[w] += 1
    hwlst.append([h,w])

hmax = max(hlst)
wmax = max(wlst)
ans = hmax + wmax -1
c = False
i = 0
for i in range(H+1):
    if hlst[i] == hmax:
        for j in range(W+1):
            if wlst[j] == wmax:
                if [i, j] not in hwlst:
                    ans += 1
                    c = True
            if c:
                break
    if c:
        break

print(ans)

### FIXED CODE ###

import sys
H, W, M = map(int, sys.stdin.readline().split())
hlst = {}
wlst = {}
hwlst = []

for i in range(M):
    h, w = sys.stdin.readline().split()
    if h in hlst:
        hlst[h] += 1
    else:
        hlst[h] = 1

    if w in wlst:
        wlst[w] += 1
    else:
        wlst[w] = 1

    hwlst.append([h, w])

h = max(hlst.values())
w = max(wlst.values())
hmax = [i for i in hlst if hlst[i] == h]
wmax = [i for i in wlst if wlst[i] == w]
num = len(hmax)*len(wmax)
ans = h + w -1


for i in hwlst:
    if hlst[i[0]] == h and wlst[i[1]] == w:
        num -= 1

if num == 0:
    print(h+w-1)
else:
    print(h+w)
m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())

if m1, d1 = 1,31:
  print('1')
elif m1, d1 = 2, 28:
  print('1')
elif m1, d1 = 3, 31:
  print('1')
elif m1, d1 = 4, 30:
  print('1')
elif m1, d1 = 5, 31:
  print('1')
elif m1, d1 = 6, 30:
  print('1')
elif m1, d1 = 7, 31:
  print('1')
elif m1, d1 = 8, 31:
  print('1')
elif m1, d1 = 9, 30:
  print('1')
elif m1, d1 = 10, 31:
  print('1')
elif m1, d1 = 11, 30:
  print('1')
else:
  print('0')

### FIXED CODE ###

m1, d1 = map(int, input().split())
m2, d2 = map(int, input().split())

if m1 ==1 and d1 == 31:
  print('1')
elif m1==2 and d1 == 28:
  print('1')
elif m1==3 and d1 == 31:
  print('1')
elif m1==4 and d1 == 30:
  print('1')
elif m1==5 and d1 == 31:
  print('1')
elif m1==6 and d1 == 30:
  print('1')
elif m1==7 and d1 == 31:
  print('1')
elif m1==8 and d1 == 31:
  print('1')
elif m1==9 and d1 == 30:
  print('1')
elif m1==10 and d1 == 31:
  print('1')
elif m1==11 and d1 == 30:
  print('1')
else:
  print('0')
def gcd(a,b): #a<=b
  if b%a==0:
    return a
  else:
    c=b%a
    return gcd(c,a)

x=gcd(8,12)

n=int(input())
li = [int(input()) for i in range(n)]
li.sort()

a=gcd(li[0],li[1])
b=li[0]*li[1]/a
c=a

for i in range(n-2):
  a=gcd(li[i+2],a)
  b=li[i+2]*c/a
  c=a

b=int(b)

print(b)

### FIXED CODE ###

a=int(input())
li = [int(input()) for i in range(a)]
li.sort()

def gcd(x,y):
  #x<=y
  if x==y:
    return x
  else:
    if y%x==0:
      return x
    else:
      return gcd(y%x,x)


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

ans=li[0]
for i in range(a-1):
  if ans<=li[i+1]:
    ans=lcm(ans,li[i+1])
  else:
    ans=lcm(li[i+1],ans)

print(int(ans))
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)] # a_0...a_(M-1)

def fib(x): # フィボナッチ数列
    a, b = 1, 1
    if x == 0:
        return a
    elif x == 1:
        return b
    else:
        for i in range(x-1):
            a, b = b, a + b
        return b
"""
# 再帰だとTLEとかREとかになるよ
def fib(x): # フィボナッチ数列
    if x == 0:
        return(1)
    elif x == 1:
        return(1)
    else:
        return(f(x-1) + f(x-2))
"""

ans = 0
MOD = 10**9 + 7

if M == 0:
    ans += fib(N) % MOD
    print(ans)
else:
    ans += fib((a[0]-1) - 0) % MOD # 0段目からa_0-1段目に上る(その後a_0段目を飛ばしてa_0+1段目に上る)
    for i in range(1, M): # iは1からM-1
        stair = (a[i] - 1) - (a[i-1] + 1) # 登る段数
        if stair >= 0:
            ans *= fib(stair) % MOD # a_(i-1)+1段目からa_i-1段目に上る(その後a_i段目を飛ばしてa_i+1段目に上る)
        else:
            ans = 0
            break
    ans *= fib(N - (a[M-1] + 1)) % MOD # a_M-1段目からN段目に上る
    print(ans % MOD)


### FIXED CODE ###

P, Q, R = map(int, input().split())

ans = min(P+Q, Q+R, R+P)

print(ans)
h,w = (int(i) for i in input().split())
s = []
for i in range(h):
    s.append(input())

isPaintable = True
for y in range(h):
    for x in range(w):
        if s[x][y]=="#":
            if x-1>=0 and s[x-1][y]=="#":
                continue
            elif y-1>=0 and s[x][y-1]=="#":
                continue
            elif x+1<w and s[x+1][y]=="#":
                continue
            elif y+1<h and s[x][y+1]=="#":
                continue
            isPaintable=False
if isPaintable:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

h,w = (int(i) for i in input().split())
s = []
for i in range(h):
    s.append(input())

isPaintable = True
for y in range(h):
    for x in range(w):
        if s[y][x]=="#":
            if x-1>=0 and s[y][x-1]=="#":
                continue
            elif y-1>=0 and s[y-1][x]=="#":
                continue
            elif x+1<w and s[y][x+1]=="#":
                continue
            elif y+1<h and s[y+1][x]=="#":
                continue
            isPaintable=False
if isPaintable:
    print("Yes")
else:
    print("No")
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

x=int(input())
a=list(map(int, input().split()))
ans=0
chk=lcm(a[0],a[1])
for i in range(x):
	chk=lcm(chk,a[i])
for i in range(x):
	ans=ans+(chk//a[i])
print(ans%(10**9+7))

### FIXED CODE ###

import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

x=int(input())
a=list(map(int, input().split()))
ans=0
if x==1:
	print(1)
else:
	chk=lcm(a[0],a[1])
	for i in range(x):
		chk=lcm(chk,a[i])
	for i in range(x):
		ans=ans+(chk//a[i])
	print(ans%(10**9+7))