Harryxun/stf_run huggingface dataset:
import collections
import sys

def solve(n, A, B):
  Ac = {}
  ABc = {}
  for a in A:
    Ac[a] = 1 + Ac.get(a, 0)
    ABc[a] = 1 + ABc.get(a, 0)
  Bc = {}
  for b in B:
    Bc[b]  = 1 + Bc.get(b, 0)
    ABc[b] = 1 + ABc.get(b, 0)
  cAB = sorted([(c, ab) for ab, c in ABc.items()])
  #print(cAB)
  pool = collections.deque()  #[bbbb]   # [(b, count)], FIFO to match at the end

  matched = {}  # {a: bbbb}    # {a: {b, count}
  current = n   # how many are not matched yet
  for c, ab in cAB[::-1]:
    if c > current + len(pool):
      print('No')
      return
    matched[ab] = []
    while c > current:
      # take c - current from pool, add to matched
      c -= 1
      matched[ab].append(pool.popleft())
    # add (ab, Bc[ab]) to pool
    current -= Bc[ab]
    for _ in range(Bc[ab]):
      pool.append(ab)
  #  print(pool, matched)
  skipped = []
  for c, ab in cAB:
    # take c - matched[ab] from pool, add to matched
    nn = Ac[ab]-len(matched[ab])
    while skipped and  Ac[ab]-len(matched[ab]) > 0:
      matched[ab].append(skipped.pop())
    while Ac[ab]-len(matched[ab]) > 0:
      p = pool.popleft()
      if p == ab:
        skipped.append(p)
      else:
        matched[ab].append(p)
   # print(pool, matched)

  ans = []
  for a, bb in sorted(matched.items()):
    ans += [str(b) for b in bb]
  print('Yes')
  print(' '.join(ans))


def main():
  input = sys.stdin.readline
  n = int(input())
  A = list(map(int, input().split()))
  B = list(map(int, input().split()))
  solve(n, A, B)

main()

### FIXED CODE ###

import collections
import sys

def solve(n, A, B):
  Ac = {}
  ABc = {}
  Bc = {}
  for a in A:
    Ac[a] = 1 + Ac.get(a, 0)
    ABc[a] = 1 + ABc.get(a, 0)
    Bc[a] = Bc.get(a, 0)
  for b in B:
    Ac[b] = Ac.get(b, 0)
    Bc[b]  = 1 + Bc.get(b, 0)
    ABc[b] = 1 + ABc.get(b, 0)
  cAB = sorted([(c, ab) for ab, c in ABc.items()])
  #print(cAB)
  pool = collections.deque()  #[bbbb]   # [(b, count)], FIFO to match at the end

  matched = {}  # {a: bbbb}    # {a: {b, count}
  current = n   # how many are not matched yet
  for c, ab in cAB[::-1]:
    if c > current + len(pool):
      print('No')
      return
    matched[ab] = []
    while c > current:
      # take c - current from pool, add to matched
      c -= 1
      matched[ab].append(pool.popleft())
    # add (ab, Bc[ab]) to pool
    current -= Bc[ab]
    for _ in range(Bc[ab]):
      pool.append(ab)
  #print(pool, matched)
  skipped = []
  for c, ab in cAB:
    # take c - matched[ab] from pool, add to matched
    nn = Ac[ab]-len(matched[ab])
    while skipped and  Ac[ab]-len(matched[ab]) > 0:
      matched[ab].append(skipped.pop())
    while Ac[ab]-len(matched[ab]) > 0:
      p = pool.popleft()
      if p == ab:
        skipped.append(p)
      else:
        matched[ab].append(p)
      #print(ab, pool, matched, skipped)

  ans = []
  for a, bb in sorted(matched.items()):
    ans += [str(b) for b in bb]
  print('Yes')
  print(' '.join(ans))


def main():
  input = sys.stdin.readline
  n = int(input())
  A = list(map(int, input().split()))
  B = list(map(int, input().split()))
  solve(n, A, B)

main()
s = 0
num_min = L + 1 - 1
num_max = L + N - 1
if 0 < num_min:
    s = sum([L + i - 1 for i in range(1, N+1)] ) - num_min
elif num_max < 0:
    s = sum([L + i - 1 for i in range(1, N+1)] ) - num_max
else:
    s = sum([L + i - 1 for i in range(1, N+1)] )
print(s)

### FIXED CODE ###

N, L = map(int, input().split())
num_min = L + 1 - 1
num_max = L + N - 1
if 0 < num_min:
    s = sum([L + i - 1 for i in range(1, N+1)] ) - num_min
elif num_max < 0:
    s = sum([L + i - 1 for i in range(1, N+1)] ) - num_max
else:
    s = sum([L + i - 1 for i in range(1, N+1)] )
print(s)
k, x = map(int, input().split())
for i in range(x-k+1,x+k-1)
print (i)

### FIXED CODE ###

k, x = map(int, input().split())
for i in range(x-k+1,x+k):
	print (i)
n = int(input())
s = input()

arr = []
arr.append(s[1])
for i in range(n-1):
    if s[i+1] != s[i]:
        arr.append(s[i+1])
        
c = len("".join(arr))
if c == 0:
    print(1)
else:
    print(c)



### FIXED CODE ###

n = int(input())
s = input()

arr = []
arr.append(s[0])
for i in range(n-1):
    if s[i+1] != s[i]:
        arr.append(s[i+1])


c = len(arr)
print(c)
import sys
input = sys.stdin.readline
import itertools

N = int(input())
A = [int(x) for x in input().split()]

# B_x = max {A_y | y\subset x}
# と思ったが、2元ずつ持つ必要がある。
# (値、何番から来たか)
B = []
for n,a in enumerate(A):
    arr = [(a,n)]
    m = n
    while m:
        bit = m & (-m)
        arr += B[n - bit]
        m -= bit
    se = set(arr)
    B.append(sorted(se, reverse=True)[:2])

answer = itertools.accumulate([x+y for (x,i),(y,j) in B[1:]], max)
print('\n'.join(map(str,answer)))

### FIXED CODE ###

import sys
input = sys.stdin.readline
from heapq import heappushpop

N = int(input())
A = [int(x) for x in input().split()]

# B_x = max {A_y | y\subset x}
# と思ったが、2元ずつ持つ必要がある。
# (値、何番から来たか)
B = []
for n,a in enumerate(A):
    arr = [(0,0),(a,n)]
    m = n
    while m:
        bit = m & (-m)
        (x,i),(y,j) = B[n-bit]
        if (x,i) != arr[-1]:
            heappushpop(arr,(x,i))
        if (y,j) != arr[-1]:
            heappushpop(arr,(y,j))
        m -= bit
    B.append(arr)

answer = [0]
for (x,i),(y,j) in B[1:]:
    z = answer[-1]
    if z < x + y:
        z = x + y
    answer.append(z)
print('\n'.join(map(str,answer[1:])))
S = input()
K = int(input())

con = 0

for i in S:
  if i == "1":
    con += 1
    

if K < con:
  print(1)
else:
  if S[0] == "1":
    print(int(S[1]))
  else:
    print(int(S[0]))

### FIXED CODE ###

S = input()
K = int(input())

con = 0

for i in range(0,len(S)):
  if S[i] == "1":
    con += 1
  else:break

if K <= con:
  print(1)
else:
  if S[0] == "1":
    S = S.replace("1","")
    print(int(S[0]))
  else:
    print(int(S[0]))
from math import gcd
n = int(input())
t = [int(input()) for _ in range(n)]
result = t[0]
for i in range(1, n):
    result = result*t[i]//gcd(result, t[i])
print(result)

### FIXED CODE ###

from fractions import gcd
n = int(input())
t = [int(input()) for _ in range(n)]
result = t[0]
for i in range(1, n):
    result = result*t[i]//gcd(result, t[i])
print(result)
s = input()
if s[0] == '1':
  s[0] = '9'
else:
  s[0] = '1'
if s[1] == '1':
  s[1] = '9'
else:
  s[1] = '1'
if s[2] == '1':
  s[2] = '9'
else:
  s[2] = '1'
print(s)

### FIXED CODE ###

s = input()
s = list(s)
if s[0] == '1':
  s[0] = '9'
else:
  s[0] = '1'
if s[1] == '1':
  s[1] = '9'
else:
  s[1] = '1'
if s[2] == '1':
  s[2] = '9'
else:
  s[2] = '1'

print(''.join(s))
n, k = map(int, input().split())

ans = k
all = [k]
if n == 1 or k == 1 or n == 2*k or k == 2*n:
  ans = 0
else:
  all = []
  for i in range(2*n):
    n = abs(n - k)
    all.append(n)

  
print(min(ans, min(all)))

### FIXED CODE ###

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

rot = n//k
x = n

if k == 1 or n == k or n%k == 0:
  x = 0
elif rot >= 1:
  x = n - k*rot
  
t = x%k

print(min(t, abs(t-k)))
s=input()
y=lens(s)
print("x"*y)

### FIXED CODE ###

s=input()
y=len(s)
print("x"*y)
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr
    ref = arr[0]
    ref_count = 0
    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return right + [ref] * ref_count + left

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

A = [x for x in A if A.count(x) == 1]
A = quick_sort(A)

ans = 0
if len(A) == 0:
    print(ans)
    exit()
for i in range(N):
    flag = True
    for j in range(i+1, N):
        if A[i] % A[j] == 0:
            flag = False
            break
    if flag: ans += 1
print(ans)

### FIXED CODE ###

from numba import njit

N = int(input())
A = list(map(int, input().split()))
maxA = max(A)
dp = [0] * maxA

for i in range(N):
    if dp[A[i]-1] != 0:
        dp[A[i]-1] = 2
        continue
    else:
        for j in range(1, maxA//A[i]+1):
            dp[A[i]*j-1] += 1

ans = 0
for i in range(N):
    if dp[A[i]-1] == 1:
        ans += 1

print(ans)
s=list(input())
t=list("keyence")
j=0
c=0
for i in range(len(s)):
    if s[i]==t[c]:
        j+=1
        if j==7:
            if s[i+1]="":
                print("YES")
                exit()
            else:
                break
        c+=1
print("NO")

### FIXED CODE ###

import re
s=input()
if re.match("^keyence.*",s) or re.match(".*keyence$",s) or re.match("^k.*eyence$",s)  or re.match("^ke.*yence$",s) or re.match("^key.*ence$",s) or re.match("^keye.*nce$",s) or re.match("^keyen.*ce$",s)or re.match("^keyenc.*e$",s) or re.match("^keyence$",s) :
    print("YES")
else:print("NO")
N = list(input())
max_N = max(N)

if max_N < sum(N)-max_N :
  print("Yes")
else:
  print("No")

### FIXED CODE ###

Q = int(input())
N = list(map(int, input().split()))
max_N = max(N)

if max_N < sum(N)-max_N :
  print("Yes")
else:
  print("No")
def cross(p0, p1, p2):
  dx1, dx2 = p1[0] - p0[0], p2[0] - p0[0]
  dy1, dy2 = p1[1] - p0[1], p2[1] - p0[1]
  return True if dy2 * dx1 > dy1 * dx2 else False
 
while True:
  l = [float(x) for x in raw_input().split(',')]
  a = l[0:2]
  b = l[2:4]
  c = l[4:6]
  d = l[6:8]
  if((cross(a, c, b) != cross(a, c, d)) and (cross(b, d, a) != cross(b, d, c))):
    print 'YES'
  else:
    print 'NO'

### FIXED CODE ###

import sys

def cross(p0, p1, p2):
  dx1, dx2 = p1[0] - p0[0], p2[0] - p0[0]
  dy1, dy2 = p1[1] - p0[1], p2[1] - p0[1]
  return dy2 * dx1 - dy1 * dx2
 
for line in iter(sys.stdin.readline, ''):
  l = [float(r) for r in line.split(',')]
  a, b, c, d = l[0:2], l[2:4], l[4:6], l[6:8]
  print 'YES' if (cross(a, c, b) * cross(a, c, d)) < 0 and (cross(b, d, a) * cross(b, d, c) < 0) else 'NO'
n, m = map(int, input().split())


m = (n-1) // 2
a = (n - 1) // 2
d = 1
memo = set([])
cnt = 0
for i in range(m):

    if (n - d in memo) or (d * 2 == n)):
        cnt += 1
        d += 1
    memo.add(d)
    if cnt > 1 or a < 1 or a+d > n:
        print(1/0)
    print(a, a+d)
    a -= 1
    d += 2


### FIXED CODE ###

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

a = (n - 1) // 2
d = 1
memo = set([])
cnt = 0
for i in range(m):

    if (n - d in memo) or (2*d == n):
        cnt += 1
        d += 1
    memo.add(d)
    if cnt > 1 or a < 1 or a+d > n:
        print(1/0)
    print(a, a+d)
    a -= 1
    d += 2
#python3.4
def inpul(): return list(map(int, input().split()))

N, M = inpul()
X = inpul()

if(N >= M):
    print(0)
else:
  new_list = sorted(X)
  diff_list = [new_list[i+1] - new_list[i] for i in range(M-1)]
  new_dif_list = sorted(diff_list, reverse = True)

  if(N  >= 2):
    for i in range(N-1):
        new_dif_list.pop(0)

print(sum(new_dif_list))


### FIXED CODE ###

#python3.4
def inpul(): return list(map(int, input().split()))

N, M = inpul()
X = inpul()
new_list = sorted(X)
diff_list = [new_list[i+1] - new_list[i] for i in range(M-1)]
new_dif_list = sorted(diff_list, reverse = True)

if(N >= M):
    print(0)

else:
  if(N  >= 2):
      for i in range(N-1):
        new_dif_list.pop(0)

  print(sum(new_dif_list))
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return map(int, sys.stdin.readline().split())
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())


def FLIST(n):
    res = [1]
    for i in range(1, n+1):
        res.append(res[i-1]*i % DVSR)
    return res


class ModInt:
    def __init__(self, a, dvsr=DVSR):
        self.dvsr = dvsr
        self.value = a % dvsr

    def __iadd__(self, b):
        self.value += b
        self.value %= self.dvsr

    def __isub__(self, b):
        self.value -= b
        self.value %= self.dvsr

    def __imul__(self, b):
        self.value *= b
        self.value %= self.dvsr

    def __ifloordiv__(self, b):
        self.value *= pow(b, self.dvsr - 2, self.dvsr)
        self.value %= self.dvsr

    def __str__(self):
        return str(self.value)


N, M = LI()
FACT = FLIST(M)


def NCR(n, r):
    res = FACT[n-r]
    res *= FACT[r]
    res %= DVSR
    res = INV(res)
    res *= FACT[n]
    res %= DVSR
    return res


def NPR(n, r):
    res = FACT[n]*INV(FACT[n-r])
    res %= DVSR
    return res


ALL = ModInt(NPR(M, N), DVSR)
ALL *= ALL.value

PAT = ModInt(0)
for i in reversed(range(1, N+1)):
    v = ModInt(NCR(N, i), DVSR)
    v *= NPR(M, i)
    v *= NPR(M-i, N-i)
    v *= NPR(M-i, N-i)
    PAT = ModInt(v.value - PAT.value, DVSR)

print(ModInt(ALL.value - PAT.value, DVSR))


### FIXED CODE ###

import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return map(int, sys.stdin.readline().split())
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())


def FLIST(n):
    res = [1]
    for i in range(1, n+1):
        res.append(res[i-1]*i % DVSR)
    return res


N, M = LI()
FACT = FLIST(M)


def NCR(n, r):
    res = 1
    res *= FACT[n-r]
    res *= FACT[r]
    res %= DVSR
    res = INV(res)
    res *= FACT[n]
    res %= DVSR
    return res


def NPR(n, r):
    res = 1
    res *= FACT[n]
    res *= INV(FACT[n-r])
    res %= DVSR
    return res


ALL = NPR(M, N)
ALL %= DVSR
ALL *= ALL
ALL %= DVSR


PAT = 0
for i in reversed(range(1, N+1)):
    v = NCR(N, i)
    v *= NPR(M, i)
    v %= DVSR
    v *= NPR(M-i, N-i)
    v %= DVSR
    v *= NPR(M-i, N-i)
    v %= DVSR
    PAT = v - PAT
    PAT %= DVSR

print((ALL - PAT) % DVSR)
from heapq import heappop,heappush

input=open(0).readline
n,k=map(int,input().split())
res={}
for i in range(n):
    a,b=map(int,input().split())
    res[a]=res.get(a,0)+b

que=[]
for key,val in res.items():
    heappush(que,(key,val))

while k:
    key,val=heappop(que)
    if val<=k:
        print(key)
        exit()
    k-=val

### FIXED CODE ###

from heapq import heappop,heappush

input=open(0).readline
n,k=map(int,input().split())
res={}
for i in range(n):
    a,b=map(int,input().split())
    res[a]=res.get(a,0)+b

que=[]
for key,val in res.items():
    heappush(que,(key,val))

while k:
    key,val=heappop(que)
    if val>=k:
        print(key)
        exit()
    k-=val
def main():
  	from decimal import Decimal
    a,b = map(decimal,input().split())
    print(int(a*b))
    return
main()

### FIXED CODE ###

def main():
    from decimal import Decimal
    a,b = map(Decimal,input().split())
    print(int(a*b))
    return
main()
import numpy as np

N, M, X = map(int, input().split())
C = []
A = np.ndarray((N, M), dtype=int)
for j in range(N):
    c, *a = [int(i) for i in input().split()]
    C.append(c)
    A[j] = a

ans = 10**20
for i in range(2 ** N):
    cost = 0
    sk = np.zeros(M, dtype=int)
    for j in range(N):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            cost += C[j]
            sk += A[j, :]
    if all(s >= X for s in sk):
        ans = min(ans, cost)

if ans == 10**20:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

import numpy as np

N, M, X = map(int, input().split())
C = []
A = np.ndarray((N, M), dtype=int)
for j in range(N):
    c, *a = [int(i) for i in input().split()]
    C.append(c)
    A[j] = a

ans = 10**20
for i in range(2 ** N):
    cost = 0
    sk = np.zeros(M, dtype=int)
    for j in range(N):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            cost += C[j]
            sk += A[j, :]
    if all(s >= X for s in sk):
        ans = min(ans, cost)

if ans == 10**20:
    print(-1)
else:
    print(ans)
k = int(input())
sum=0
for a in range(1,k+1):
    for b in range(1,k+1):
        g1 = math.gcd(a,b)
        for c in range(1,k+1):
            sum += math.gcd(g1,c)
print(sum)

### FIXED CODE ###

mod = 10**9 + 7
import math 
from bisect import bisect_left 
from collections import Counter
from itertools import combinations
 
def ain():
    return map(int, input().split())
def fain():
    return map(float, input().split())
 
def mc2(s):
    return (s*(s-1))//2 + s
    
# for tc in range(int(input())):
#     n = int(input())
    
#     print(ans)

k = int(input())
sum=0
for a in range(1,k+1):
    for b in range(1,k+1):
        g1 = math.gcd(a,b)
        for c in range(1,k+1):
            sum += math.gcd(g1,c)
print(sum)
# python3 pan3.py
def dp():
    n,w = map(int,input().split())
    lis = (map(int,input().split()) for i in range(n))
    
    dpp = [0] * (w + 1)
    for weight, value in lis:
        for j in range(w,weight-1,-1):
            dp = dpp[j-weight] + value
            if dpp[j] < dp:
                dpp[j] = dp
    return max(dpp)
print(dp())

### FIXED CODE ###

n = int(input())
lis = list(map(int,input().split()))
ans = [10 ** 9 for i in range(n+5)]
ans[0] = 0
for i in range(n):
    if i < n-1:
        ans[i+1] = min(ans[i+1],ans[i]+abs(lis[i+1]-lis[i]))
    if i < n-2:
        ans[i+2] = min(ans[i+2],ans[i]+abs(lis[i+2]-lis[i]))
print(ans[n-1])
a = int(input())
 
if a[0]==a[1]==a[2] or a[1]==a[2]==a[3] or a[0]==a[1]==a[2]==a[3]:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a = str(input())
 
if a[0]==a[1]==a[2] or a[1]==a[2]==a[3] or a[0]==a[1]==a[2]==a[3]:
  print('Yes')
else:
  print('No')
A, B = map(int,input().split())
for i in range(A, B+1):
  str_i = str(i)
  if str_i[0] == str_i[4] and str_i[1] == str_i[2]:
    ans += 1
  else:
    continue

print(ans)

### FIXED CODE ###

A, B = map(int,input().split())
ans = 0
for i in range(A, B+1):
  str_i = str(i)
  if str_i[0] == str_i[4] and str_i[1] == str_i[3]:
    ans += 1
  else:
    continue

print(ans)
a = int(input())
b = int(input())

print(max(a+b,a-b,a*b))

### FIXED CODE ###

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

print(max(a+b,a-b,a*b))
n, y = map(int, input().split())

for nx in range(n+1):
   for ny in range(n-i+1):
      if (1000 * nx + 5000 + ny * 1000 * (n - nx - ny) == y):
         print(nx, ny, n - nx - ny)
         exit()

print(-1, -1, -1)


### FIXED CODE ###

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

for i in range(n+1):
   for j in range(n-i+1):
      if (10000 * i + 5000 * j + 1000 * (n - i - j) == y):
         print(i, j, n - i - j)
         exit()

print(-1, -1, -1)
n, m, x = map(int,input().split())
c = [list(map(int, input().split())) for i in range(n)]
ans = float('inf')
money = []

for i in range(2**n):
  temp_money = 0
  temp_skill = [0]*m
  for j in range(n):
    if (i >> j) & 1:
      temp_money += c[j][0]
      temp_skill = [a + b for a, b in zip(temp_skill, c[j][1:m+1])]
    if all([i >= x for i in temp_skill])==True:
      money.append(temp_money)

ans = min(ans,min(money))
if ans == float("inf"):
  ans = -1

print(ans)

### FIXED CODE ###

n, m, x = map(int,input().split())
c = [list(map(int, input().split())) for i in range(n)]
ans = float('inf')
money = [float('inf')]

for i in range(2**n):
  temp_money = 0
  temp_skill = [0]*m
  for j in range(n):
    if (i >> j) & 1:
      temp_money += c[j][0]
      temp_skill = [a + b for a, b in zip(temp_skill, c[j][1:m+1])]
    if all([i >= x for i in temp_skill])==True:
      money.append(temp_money)

ans = min(ans,min(money))
if ans == float("inf"):
  ans = -1

print(ans)
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = sum(B)
for i, j in zip(A, A[1:]):
    if i == j+1:
        ans += C[i-1]
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = sum(B)
for i, j in zip(A, A[1:]):
    if j == i+1:
        ans += C[i-1]
print(ans)
import numpy as np
#かけて最小公倍数になる　そのために必要な数がB
from fractions import gcd
N=int(input())
mod=10**9+7
A=list(map(int, input().split()))
def lcm(a,b):
  return a/gcd(a,b)*b

LCM=lcm(A[0],A[1])
#LCM%=mod
for i in range(2,N):
  LCM=lcm(LCM, A[i])
  #LCM%=mod
  
#print(LCM)
ans=0
for a in A:
  ans+=LCM//a
  ans%=mod

print(int(ans%mod))



### FIXED CODE ###


#かけて最小公倍数になる　そのために必要な数がB
from fractions import gcd
N=int(input())
if N==1:
  print(1)
  exit()

mod=10**9+7
A=list(map(int, input().split()))
def lcm(a,b):
  return a//gcd(a,b)*b

if N==2:
  LCM=lcm(A[0],A[1])
  ans=((LCM//A[0])+(LCM//A[1]))%mod
  print(ans)
  exit()

LCM=1
#LCM%=mod
for a in A:
  LCM=lcm(LCM, a)
  #LCM%=mod
  
#print(LCM)
ans=0
for a in A:
  ans+=LCM//a
  #ans%=mod

print(int(ans%mod))
n, m = list(map(int, input().split()))
if m > 0:
  a = [int(input()) for i in range(m)]
else:
  a = []

pt = [1]
if a[0] == 1:
  pt.append(0)
else:
  pt.append(1)

for i in range(2, n+1):
  if (i in a):
    pt.append(0)
  else:
    if (i-1 in a):
      pt.append(pt[i-2])
    else:
      pt.append(pt[i-1] + pt[i-2])

pat = (pt[-1] % 1000000007)
print(pat)


### FIXED CODE ###

n, m = list(map(int, input().split()))
if m > 0:
  a = set([int(input()) for i in range(m)])
else:
  a = set([])

if n == 1:
  pat = 1
else:
  pt = [1]
  if (1 in a):
    pt.append(0)
  else:
    pt.append(1)

  for i in range(2, n + 1):
    if (i in a):
      pt.append(0)
    else:
      if (i-1 in a):
        pt.append(pt[i-2])
      else:
        pt.append(pt[i-1] + pt[i-2])

  pat = (pt[-1] % 1000000007)
print(pat)
s = input()
N = len(s)
s_trim = ''.join([c for c in s if c != 'x'])
N_trim = len(s_trim)

def check_anagram():
    for i in range(N_trim):
        j = N_trim - 1 - i
        if s_trim[i] != s_trim[j]:
            return False
    return True

def solve():
    if not check_anagram():
        return -1

    # Center of anagram
    pr = N_trim // 2
    pl = pr
    if N_trim % 2 == 0:
        pl -= 1

    xl = 0
    tl = 0
    while xl < N:
        if s[xl] != 'x':
            assert s[xl] == s_trim[tl]
            if tl == pl:
                break
            tl += 1
        xl += 1

    if N_trim % 2 == 1:
        xr = xl
    else:
        xr = xl + 1
        while s[xr] == 'x':
            xr += 1

    cost = 0
    while True:
        assert s[xl] == s_trim[pl]
        assert s[xr] == s_trim[pr]
        assert s[xl] == s[xr]
        assert s_trim[pl] == s_trim[pr]
        pl -= 1; pr += 1
        while True:
            xl -= 1; xr += 1
            if not (xl >= 0 and xr < N and s[xl] == 'x' and s[xr] == 'x'):
                break
        while xl >= 0 and s[xl] == 'x':
            cost += 1
            xl -= 1
        while xr < N and s[xr] == 'x':
            cost += 1
            xr += 1
        if pl < 0 and pr >= N_trim and xl < 0 and xr >= N:
            return cost

print(solve())


### FIXED CODE ###

s = input()
N = len(s)
s_trim = ''.join([c for c in s if c != 'x'])
N_trim = len(s_trim)

def check_anagram():
    for i in range(N_trim):
        j = N_trim - 1 - i
        if s_trim[i] != s_trim[j]:
            return False
    return True

def solve():
    if not check_anagram():
        return -1
    if N_trim == 0:
        return 0
    # Center of anagram
    pr = N_trim // 2
    pl = pr
    if N_trim % 2 == 0:
        pl -= 1

    xl = 0
    tl = 0
    while xl < N:
        if s[xl] != 'x':
            # assert s[xl] == s_trim[tl]
            if tl == pl:
                break
            tl += 1
        xl += 1

    if N_trim % 2 == 1:
        xr = xl
    else:
        xr = xl + 1
        while s[xr] == 'x':
            xr += 1

    cost = 0
    while True:
        # assert s[xl] == s_trim[pl]
        # assert s[xr] == s_trim[pr]
        # assert s[xl] == s[xr]
        # assert s_trim[pl] == s_trim[pr]
        pl -= 1; pr += 1
        while True:
            xl -= 1; xr += 1
            if not (xl >= 0 and xr < N and s[xl] == 'x' and s[xr] == 'x'):
                break
        while xl >= 0 and s[xl] == 'x':
            cost += 1
            xl -= 1
        while xr < N and s[xr] == 'x':
            cost += 1
            xr += 1
        if pl < 0 and pr >= N_trim and xl < 0 and xr >= N:
            return cost

print(solve())