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

from collections import Counter 
N = int(input())
A = Counter(list(map(int, input().split())))
Q = int(input())

for _ in range(Q):
    B, C = map(int, input().split())
    if B in A.keys():
        if C in A.keys():
            A[C] += A[B]
        else:
            A[C] = A[B]
        A[B] = 0
    ans = 0
    for k, v in A.items():
        ans += k*v
    print(ans)

### FIXED CODE ###

from collections import Counter 
N = int(input())
a = list(map(int, input().split()))
A = Counter(a)
Q = int(input())

ans = sum(a)
for _ in range(Q):
    B, C = map(int, input().split())
    if B in A.keys():
        if C in A.keys():
            A[C] += A[B]
        else:
            A[C] = A[B]
        ans += (C-B)*A[B]
        A[B] = 0
    print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
connections = [list(map(int, input().split())) for _ in range(m)]
weights = [2e5 + 10] * n
weights[0] = 1
directions = [1] * n
for min_weight in range(1, m + 1):
    for con in connections:
        r1 = con[0]
        r2 = con[1]
        w1 = weights[r1 - 1]
        w2 = weights[r2 - 1]
        if w1 <= min_weight and w2 <= min_weight:
            continue
        if w1 < 2e5 + 10 and w1 + 1 < w2:
            weights[r2 - 1] = w1 + 1
            directions[r2 - 1] = r1
        if w2 < 2e5 + 10 and w2 + 1 < w1:
            weights[r1 - 1] = w2 + 1
            directions[r1 - 1] = r2

if max(weights) > 2e5 + 5:
    print("No")
else:
    print("Yes")
    for d in directions[1:]:
        print(d)

### FIXED CODE ###

import sys
from collections import deque
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, M = map(int, readline().split())
 
G = [[] for _ in range(N + 1)]
m = map(int, read().split())
for a, b in zip(m, m):
    G[a].append(b)
    G[b].append(a)
 
par = [0] * (N + 1)
visited = [0] * (N + 1)
root = 1
visited[root] = 1
q = deque([root])
while q:
    v = q.popleft()
    for w in G[v]:
        if visited[w]:
            continue
        visited[w] = 1
        par[w] = v
        q.append(w)
 
print('Yes')
print(*par[2:], sep='\n')
### BUGGY CODE ###

def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

N,M,K=MI()
A=[0]+LI()
B=[0]+LI()
from itertools import accumulate
A=list(accumulate(A))
B=list(accumulate(B))
ans=0
for i in range(N+1):
  if A[i]>K:
    break
  for j in range(M,-1,-1):
    if A[i]+B[j]>K:
      continue
    ans=max(ans,i+j)
    break
print(ans)

### FIXED CODE ###

N,M,K=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=[0]
B=[0]
ans=0
j=M
for i in range(N):
  A.append(A[i]+a[i])
for i in range(M):
  B.append(B[i]+b[i])
for i in range(N+1):
  if A[i]>K:
    break
  while A[i]+B[j]>K:
    j-=1
  ans=max(ans,i+j)
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

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

    return gcd(y % x, x)


def lcd(x, y):
    g = gcd(x, y)
    return x * y // g


l = 1
for e in a:
    l = lcd(l, e)

ans = 0
for e in a:
    ans += l // e
    ans %= mod

print(ans)



### FIXED CODE ###

from fractions import gcd


def lcm(a, b):
    return a * b // gcd(a, b)


n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

l = 1
for e in a:
    l = lcm(l, e)

l %= mod

ans = 0
for e in a:
    ans += l * pow(e, mod - 2, mod)
    ans %= mod

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

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

ans_list = {}

for i in range(N):
    for j in range(i+1, N):
        if not S[j + 1:N]:
            continue
        elif S[i] + S[j] not in ans_list:
            ans_list[S[i] + S[j]] = set(S[j + 1:N])
        else:
            ans_list[S[i] + S[j]] | set(S[j+1:N])
count = 0
# print(ans_list)
ans_len_list = [len(value) for value in ans_list.values()]
print(sum(ans_len_list))

### FIXED CODE ###

N = int(input())
S = list(input())
visited = {}

count = 0

for i, s in enumerate(S):
    if s in visited:
        continue
    visited[s] = []
    for j, s2 in enumerate(S[i+1:N-1]):
        # print(s, s2, S[i + j + 2:N])
        if s2 in visited[s]:
            continue
        count += len(set(S[i + j + 2:N]))
        visited[s].append(s2)
        # print(s, s2, set(S[j + 1:N]))
print(count)
### BUGGY CODE ###

from sys import setrecursionlimit
setrecursionlimit(10**8)

X, K, D = map(int, input().split())


for i in range(K):
    if abs(X + D) < abs(X - D):
        X = X + D
    else:
        X = X - D
    if abs(X - D) > abs(X) and abs(X + D) > abs(X):
        if (K - i - 1) % 2 == 1:
            if abs(X - D) < abs(X + D):
                X = X - D
            else:
                X = X + D
        break

print(abs(X))

### FIXED CODE ###

from sys import setrecursionlimit

setrecursionlimit(10 ** 8)


def main(x, k, d):
    for i in range(k):
        if abs(x + d) < abs(x - d):
            x = x + d
        else:
            x = x - d

        if abs(x - d) > abs(x) and abs(x + d) > abs(x):
            if (k - i - 1) % 2 == 1:
                if abs(x - d) < abs(x + d):
                    x = x - d
                else:
                    x = x + d
            break

    print(abs(x))


def sub(x, k, d):
    print(abs(x) - d * k)


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

if abs(a) - b * c >= 0:
    sub(a, b, c)
else:
    main(a, b, c)
### BUGGY CODE ###

import itertools

N = int(input())
nums = list(map(int, input().split()))
ans = 0
nums = itertools.combinations(nums, 3)
for num in nums:
    a = num[0] < num[1] + num[2]
    b = num[1] < num[2] + num[0]
    c = num[2] < num[0] + num[1]
    if a and b and c:
        ans += 1
print(ans)

### FIXED CODE ###

import bisect

N = int(input())
nums = list(map(int, input().split()))
nums.sort()
ans = 0
for a in range(N - 2):
    for b in range(a + 1, N - 1):
        ind = bisect.bisect_left(nums, nums[a] + nums[b])
        ans += ind - 1 - b
print(ans)
### BUGGY CODE ###

s = input()
ans = 0
index = 0
def f(n):
    global ans, index
    lenn = len(n)
    while index < lenn and (n[index] < '5' or (n[index] == '5' and (index == lenn - 1 or n[index+1] <= '4'))):
        ans += int(n[index])
        index += 1
    if index < lenn:
        ans += 1
        f(str(10**len(n)-int(n)))
f(s)
print(ans)


### FIXED CODE ###

n = input()
lenn = len(n)

dp = [0, 10000]
for d in reversed(n):
    d = int(d)
    dp = [min(d + dp[0], d + 1 + dp[1]), min(10 - d + dp[0], 9 - d + dp[1])]

print(min(dp[0], 1 + dp[1]))
### BUGGY CODE ###

p = 10 ** 9 + 7
n,a,b = map(int,input().split())
k=max(a,b)
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
com=[0]*(k+1)
com[0]=1
for i in range(1, k+1):
  com[i]=((com[i-1]*(n-i+1))*modinv(i,p))%p
print((2**n-1-com[a]-com[b])%p)

### FIXED CODE ###

p = 10 ** 9 + 7
n,a,b = map(int,input().split())
k=max(a,b)
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
com=[0]*(k+1)
com[0]=1
for i in range(1, k+1):
  com[i]=((com[i-1]*(n-i+1))*modinv(i,p))%p
print((pow(2,n,p)-1-com[a]-com[b])%p)
### BUGGY CODE ###

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

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

candidate = []
candidate.extend(A)

for j in range(M):
    b, c = map(int, input().split())
    
    if b > N:
        b = N

    if c >= min(candidate):
        candidate.extend([c] * b)
        
    candidate = sorted(candidate, reverse=True)[:N]
        
print(sum(candidate))

### FIXED CODE ###

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

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

BC = []

for j in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))
    
sorted_BC = sorted(BC, reverse=True, key=lambda item: item[1])

candidate = []
count = N
for bc in sorted_BC:
    b = bc[0]
    c = bc[1]
    if count >= 0:
        candidate.extend([c] * b)
        count = count - b
    else:
        break
    
candidate.extend(A)

print(sum(sorted(candidate, reverse=True)[:N]))
### BUGGY CODE ###

k = int(input())
q = list(range(1, 10))
i = 0

while i < k:
    i += 1

    org = q.pop(0)
    x = org % 10

    if x != 0:
        q.append(10 * org + x - 1)

    q.append( 10 * org + x)

    if x != 9:
        q.append(10 * org + x + 1)
print(org)

### FIXED CODE ###

import collections

k = int(input())
q = collections.deque(list(range(1, 10)))
i = 0

while i < k:
    i += 1

    org = q.popleft()
    x = org % 10

    if x != 0:
        q.append(10 * org + x - 1)

    q.append( 10 * org + x)

    if x != 9:
        q.append(10 * org + x + 1)
print(org)
### BUGGY CODE ###

k, s = map(int, input().split())
ans = 0
for i in range(k + 1):
    for j in range(k + 1):
        for l in range(k + 1):
            if i + j + l == s:
                ans += 1
print(ans)


### FIXED CODE ###

k, s = map(int, input().split())
ans = 0
for i in range(k + 1):
    for j in range(i + 1):
        l = s - (i + j)
        if 0 <= l <= k and l <= j <= i:
            if i == j == l:
                ans += 1
            elif i == j or j == l or l == i:
                ans += 3
            else:
                ans += 6
print(ans)
### BUGGY CODE ###

import sys
from collections import Counter


def main():
    input = sys.stdin.buffer.readline
    h, w, m = map(int, input().split())
    h = [0] * m
    w = [0] * m
    object_set = set()
    for i in range(m):
        h[i], w[i] = map(int, input().split())
        object_set.add((h[i], w[i]))
    h_counter = Counter(h)
    w_counter = Counter(w)
    max_h_num = h_counter.most_common()[0][1]
    max_w_num = w_counter.most_common()[0][1]
    ans = max_h_num + max_w_num

    h_cand = []
    w_cand = []
    for e, n in h_counter.most_common():
        if n == max_h_num:
            h_cand.append(e)
    for e, n in w_counter.most_common():
        if n == max_w_num:
            w_cand.append(e)

    ok = False
    for h_e in h_cand:
        for w_e in w_cand:
            if (h_e, w_e) not in object_set:
                ok = True

    print(ans if ok else ans - 1)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from collections import Counter


def main():
    input = sys.stdin.buffer.readline
    h, w, m = map(int, input().split())
    h = [0] * m
    w = [0] * m
    object_set = set()
    for i in range(m):
        h[i], w[i] = map(int, input().split())
        object_set.add((h[i], w[i]))
    h_counter = Counter(h)
    w_counter = Counter(w)
    max_h_num = h_counter.most_common()[0][1]
    max_w_num = w_counter.most_common()[0][1]
    ans = max_h_num + max_w_num

    h_cand = set()
    w_cand = set()
    for e, n in h_counter.most_common():
        if n == max_h_num:
            h_cand.add(e)
    for e, n in w_counter.most_common():
        if n == max_w_num:
            w_cand.add(e)

    cnt = 0
    for h_e, w_e in object_set:
        if h_e in h_cand and w_e in w_cand:
            cnt += 1

    print(ans if cnt < len(h_cand) * len(w_cand) else ans - 1)


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

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

for i in range(n[0]):
    p[i]=(p[i]+1)/2
"""
max_sum= 0
for i in range(n[0] - n[1] + 1):
    chunk = numbers[i:i + 13]  # i, i + 1, ..., i + 12 番目の13個の数字を取り出す。
    prod = functools.reduce(operator.mul, chunk, 1)  # 部分リストのすべての値の積
    max_prod = max(max_prod, prod)  # 最大値更新    
"""    
    
max_sum=0
for i in range(n[0]-n[1]+2):
    max_sum=max(max_sum,sum(p[i:i+n[1]]))
print(max_sum)

### FIXED CODE ###

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

for i in range(n):
    p[i]=(p[i]+1)/2#p[i]を期待値に変更
    
p_sum=[0]*n
ans=0
for i in range(n):
    if i==0:
        p_sum[i]=p[i]
        ans=p_sum[i]
    elif i<k:
        p_sum[i]=p_sum[i-1]+p[i]
        if p_sum[i]>ans:
            ans=p_sum[i]
    else:
        p_sum[i]=p_sum[i-1]+p[i]-p[i-k]
        if p_sum[i]>ans:
            ans=p_sum[i]
print(ans)
### BUGGY CODE ###

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

l.sort(reverse=True)
c = 0
for i in range(len(l) - 2):
    for j in range(i + 1, len(l) - 1):
        if l[i] >= l[j] + l[j+1]:
            break
        for k in range(j + 1, len(l)):
            if l[i] < l[j] + l[k]:
                c += 1
            else:
                break
print(c)

### FIXED CODE ###

import bisect

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

l.sort()
c = 0
for i in range(len(l) - 2):
    for j in range(i + 1, len(l) - 1):
        c += bisect.bisect(l[j+1:], l[i]+l[j]-1)
print(c)
### BUGGY CODE ###

K, S = map(int, input().split())
 
cnt = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            ijk_sum = i + j + k
            if ijk_sum == S:
                cnt +=1
                break
print(cnt)

### FIXED CODE ###

K, S = map(int, input().split())
 
cnt = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i - j
        if k >= 0 and k <= K:
            cnt += 1
print(cnt)
### BUGGY CODE ###

import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, m = ns()
    e = [[] for _ in range(n)]
    for _ in range(m):
        a, b = ns()
        a, b = a - 1, b - 1
        e[a].append(b)

    s, t = ns()
    s, t = s - 1, t - 1

    ans = -1
    que = collections.deque(e[s])
    cnt = 0
    finflg = True
    while len(que) and cnt < 3*10 ** 5 and finflg:
        cnt += 1
        finflg = True

        for _ in range(3):
            for i in range(len(que)):
                nxt = que.popleft()
                if _ == 2 and nxt == t:
                    ans = cnt
                    finflg = False
                for tmp in e[nxt]:
                    que.append(tmp)

    print(-1 if ans == -1 else ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, m = ns()
    e = [[] for _ in range(n)]
    for _ in range(m):
        a, b = ns()
        a, b = a - 1, b - 1
        e[a].append(b)

    s, t = ns()
    s, t = s - 1, t - 1

    visited = [[True] * 3 for _ in range(n)]

    que = collections.deque()
    que.append([0, s])
    visited[s][0] = False
    cnt = 0
    ans = -1
    flg = True

    while que and flg:
        cnt += 1
        for _ in range(len(que)):
            i, q = que.popleft()
            for ei in e[q]:
                tmp = (i + 1) % 3
                if tmp == 0 and ei == t:
                    ans = cnt // 3
                    flg = False
                    break
                elif visited[ei][tmp]:
                    visited[ei][tmp] = False
                    que.append([tmp, ei])

    print(ans)


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

import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

h,w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
b = [list(map(int, input().split())) for i in range(h)]
c = [[set() for i in range(w)] for i in range(h)]

for i in range(h):
    for j in range(w):
        k = abs(a[i][j]-b[i][j])
        if i==0 and j==0:
            prev = set([0])
        elif i==0:
            prev = c[i][j-1]
        elif j==0:
            prev = c[i-1][j]
        else:
            prev = c[i][j-1] | c[i-1][j]
        for l in prev:
            c[i][j].add(l-k)
            c[i][j].add(l+k)

ans = min(abs(i) for i in c[-1][-1])
print(ans)

### FIXED CODE ###

import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

h,w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
b = [list(map(int, input().split())) for i in range(h)]
ma = 80*2*80
DP = [[[0]*ma for i in range(w)] for i in range(h)]

for i in range(h):
    for j in range(w):
        k = abs(a[i][j]-b[i][j])
        if i==0 and j==0:
            DP[i][j][k] = 1
            continue
        elif i == 0:
            up = min((i+j+1)*80+1, ma-k)
            for l in range(up):
                DP[i][j][l] = DP[i][j-1][abs(l-k)] | DP[i][j-1][l+k]
        elif j == 0:
            for l in range(up):
                DP[i][j][l] = DP[i-1][j][abs(l-k)] | DP[i-1][j][l+k]
        else:
            for l in range(up):
                DP[i][j][l] = DP[i][j-1][abs(l-k)] | DP[i][j-1][l+k] | DP[i-1][j][abs(l-k)] | DP[i-1][j][l+k]
for i in range(ma):
    if DP[-1][-1][i]:
        print(i)
        exit()
### BUGGY CODE ###

N = int(input())
A = [0] + [int(_) for _ in input().split()]


def is_possible(K):
    mp = {}
    for i in range(N):
        if A[i] >= A[i + 1]:
            for key in sorted(mp.keys(), reverse=True):
                if key >= A[i + 1]:
                    del mp[key]
                else:
                    break
            flag = True
            for j in range(A[i + 1] - 1, -1, -1):
                if mp.get(j, 0) < K - 1:
                    mp[j] = mp.get(j, 0) + 1
                    flag = False
                    break
            if flag:
                return False
    return True


def bis(x, y):
    if y == x + 1:
        return y
    elif is_possible((x + y) // 2):
        return bis(x, (x + y) // 2)
    else:
        return bis((x + y) // 2, y)


print(bis(0, N))


### FIXED CODE ###

import random
input()
A = [int(_) for _ in input().split()]
A = [A[0]] + [j for i, j in zip(A, A[1:]) if i >= j]
N = len(A)


def cut(array, index):
    if index < 1:
        return []
    if index <= array[0][0]:
        return [(index, array[0][1])]
    for _ in range(len(array)-1, 0, -1):
        if array[_ - 1][0] < index:
            return array[:_] + [(index, array[_][1])]


def is_possible(K):
    dp = [(A[0], 0)]
    for a in A[1:]:
        if a <= dp[-1][0]:
            dp = cut(dp, a)
        else:
            dp += [(a, 0)]
        is_added = False
        for j in range(len(dp) - 1, -1, -1):
            if dp[j][1] < K - 1:
                dp = cut(dp, dp[j][0] - 1) + [(dp[j][0], dp[j][1] + 1)]
                if dp[-1][0] < a:
                    dp += [(a, 0)]
                is_added = True
                break
        if not is_added:
            return False
    return True


def bis(x, y):
    if y == x + 1:
        return y
    elif is_possible((x + y) // 2):
        return bis(x, (x + y) // 2)
    else:
        return bis((x + y) // 2, y)


print(bis(0, N))
### BUGGY CODE ###

import queue

H, W = map(int, input().split())
A = []
dist = []
black = []
for i in range(H):
    A.append(list(input()))
    dist.append([])
    for j in range(W):
        dist[i].append(1000000)
        if A[i][j] == '#':
            black.append([i, j])

q = queue.Queue(maxsize=-1)
for b in black:
    q.put(b)

max_dist = 0
while not q.empty():
    item = q.get()

    if i < 0 or j < 0 or i > H - 1 or j > W - 1:
        continue
    if A[item[0]][item[1]] == '#':
        dist[item[0]][item[1]] = 0
    else:
        a = dist[item[0] - 1][item[1]] if item[0] > 0 else 1000000
        b = dist[item[0]][item[1] - 1] if item[1] > 0 else 1000000
        c = dist[item[0] + 1][item[1]] if item[0] < H - 1 else 1000000
        d = dist[item[0]][item[1] + 1] if item[1] < W - 1 else 1000000
        dist[item[0]][item[1]] = min(a, b, c, d) + 1
        if dist[item[0]][item[1]] > max_dist:
            max_dist = dist[item[0]][item[1]]

    if item[0] > 0 and dist[item[0]-1][item[1]] == 1000000: q.put([item[0] - 1,item[1]])
    if item[1] > 0 and dist[item[0]][item[1]-1] == 1000000: q.put([item[0], item[1] - 1])
    if item[0] < H - 1 and dist[item[0]+1][item[1]] == 1000000: q.put([item[0] + 1, item[1]])
    if item[1] < W - 1 and dist[item[0]][item[1]+1] == 1000000: q.put([item[0], item[1] + 1])

print(max_dist)

### FIXED CODE ###

H, W = map(int, input().split())
INF = H * W
A = [input() for x in range(H)]
used = [[False] * W for x in range(H)]

q = []
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            q.append([i, j])
            used[i][j] = True

max_dist = 0
counter = 0
depth = -1
while counter != INF:
    # print(q)
    # print(counter)
    for i in range(len(q) - counter):
        item = q[counter]

        if item[0] > 0 and not used[item[0]-1][item[1]]:
            q.append([item[0] - 1, item[1]])
            used[item[0] - 1][item[1]] = True
        if item[1] > 0 and not used[item[0]][item[1] - 1]:
            q.append([item[0], item[1] - 1])
            used[item[0]][item[1] - 1] = True
        if item[0] < H - 1 and not used[item[0] + 1][item[1]]:
            q.append([item[0] + 1, item[1]])
            used[item[0] + 1][item[1]] = True
        if item[1] < W - 1 and not used[item[0]][item[1] + 1]:
            q.append([item[0], item[1] + 1])
            used[item[0]][item[1] + 1] = True
        counter += 1
    depth += 1

print(depth)
### BUGGY CODE ###

import fractions

def lcm_list(numbers):
    ans = numbers[0]
    for number in numbers[1:]:
        ans = (((number * ans)) / (fractions.gcd(number, ans)))
    return ans

MOD = 10**9+7
N = input()
i = 0
arrs = list(map(int, input().split()))
lcms = lcm_list(arrs)
result = 0
for arr in arrs:
    result += (lcms/arr)
result = result%MOD
ans = str(result).replace('.0','')
print(ans)

### FIXED CODE ###


from fractions import gcd
MOD = 10**9+7
N = input()
i = 0
arrs = list(map(int, input().split()))
result = 0
lcms = 1
for number in arrs:
    lcms = (((number * lcms)) //(gcd(number, lcms)))
for arr in arrs:
    result += (lcms//arr)
result = result%MOD
ans = str(result).replace('.0','')
print(ans)
### BUGGY CODE ###

import sys
n,m=map(int,input().split())
a=[]
for i in range(m):
    a.append(int(input()))
ans=[]
for i in range(m-1):
    if a[i+1]-a[i]==1:
        print(0)
        sys.exit()
ans=[0 for i in range(n+5)]
ans[1]=1
ans[2]=2
if 1 in a:
    ans[1]=0
    ans[2]=1
if 2 in a:
    ans[2]=0
for i in range(1,n+3):
    if i+2 in a:
        ans[i+2]=0
    else:
        ans[i+2]=ans[i+1]%1000000007+ans[i]%1000000007
   
print(ans[n]%1000000007)
    
    
    

        


### FIXED CODE ###

import sys
n,m=map(int,input().split())
a=[]
d=0
for i in range(m):
    a.append(int(input()))
a.append(0)
a.append(0)
a.append(0)
ans=[]
for i in range(m-1):
    if a[i+1]-a[i]==1:
        print(0)
        sys.exit()
ans=[0 for i in range(n+5)]
ans[1]=1
ans[2]=2

if a[0]==1:
    ans[1]=0
    ans[2]=1
    d+=1
if a[0]==2 or a[1]==2:
    ans[2]=0
    d+=1

for i in range(1,n+3):
    if i+2==a[d]:
        ans[i+2]=0
        d+=1
    else:
        ans[i+2]=ans[i+1]%1000000007+ans[i]%1000000007
   
print(ans[n]%1000000007)
### BUGGY CODE ###

import math
import fractions
n = int(input())
a_ls = list(map(int,input().split()))
lcm = 1
ans = 0
mod = 10**9+7
for i in a_ls:
    lcm = lcm * i//fractions.gcd(lcm,i)
for i in a_ls:
    ans += lcm//i
print(ans%mod)


### FIXED CODE ###

import math
import fractions
n = int(input())
a_ls = list(map(int,input().split()))
lcm = 1
ans = 0
mod = 10**9+7
for i in a_ls:
    lcm = lcm * i//fractions.gcd(lcm,i)
for i in a_ls:
    ans += lcm//i
print(ans%mod)