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

from decimal import *
import sys

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

N = int(input())

A = [Decimal(input()) for i in range(N)]

nanachi = [[0, 0] for i in range(N)]

eprint(A)

def is_integer(n: Decimal):
  return n == n.to_integral_value()

for i, a in enumerate(A):
  t = 0
  while not is_integer(a):
    a *= 10
    t += 1
  nanachi[i][0] = -t
  nanachi[i][1] = -t
  while a % 2 == 0:
    a = a / 2
    nanachi[i][0] += 1
  while a % 5 == 0:
    a = a / 5
    nanachi[i][1] += 1

eprint(nanachi)

tmp = min(map(min, nanachi))

for i in range(N):
  nanachi[i][0] -= tmp
  nanachi[i][1] -= tmp

eprint(nanachi)

aaa = [[0] * 200 for i in range(200)]

for a in nanachi:
  aaa[a[0]][a[1]] += 1

acc = [[0] * 201 for i in range(201)]

for i in reversed(range(0, 200)):
  for k in reversed(range(0, 200)):
    acc[i][k] = acc[i+1][k] + acc[i][k+1] - acc[i+1][k+1] + aaa[i][k]

res = 0

for a in nanachi:
  i = max(0, - (a[0] + 2*tmp))
  k = max(0, - (a[1] + 2*tmp))
  res += acc[i][k]
  if a[0] >= -tmp and a[1] >= -tmp:
    res -= 1

res = res // 2

print(res)


### FIXED CODE ###

from decimal import *
import sys

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

N = int(input())

A = [Decimal(input()) for i in range(N)]

nanachi = [[0, 0] for i in range(N)]

eprint(A)

def is_integer(n: Decimal):
  return n == n.to_integral_value()

for i, a in enumerate(A):
  t = 0
  while not is_integer(a):
    a *= 10
    t += 1
  nanachi[i][0] = -t
  nanachi[i][1] = -t
  while a % 2 == 0:
    a = a / 2
    nanachi[i][0] += 1
  while a % 5 == 0:
    a = a / 5
    nanachi[i][1] += 1

eprint(nanachi)

tmp = min(map(min, nanachi))

for i in range(N):
  nanachi[i][0] -= tmp
  nanachi[i][1] -= tmp

eprint(nanachi)

aaa = [[0] * 200 for i in range(200)]

for a in nanachi:
  aaa[a[0]][a[1]] += 1

acc = [[0] * 201 for i in range(201)]

for i in reversed(range(0, 200)):
  for k in reversed(range(0, 200)):
    acc[i][k] = acc[i+1][k] + acc[i][k+1] - acc[i+1][k+1] + aaa[i][k]

res = 0

for a in nanachi:
  i = max(0, - (a[0] + 2*tmp))
  k = max(0, - (a[1] + 2*tmp))
  res += acc[i][k]
  if a[0] >= -tmp and a[1] >= -tmp:
    res -= 1

res = res // 2

print(res)
### BUGGY CODE ###

import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

heapq.heapify(A)

for i in range(M):
    b, c = map(int, input().split())

    count = 1
    while count <= b:
        top = A[0]
        if top <= c:
            heapq.heappop(A)
            heapq.heappush(A, c)
            count += 1
        else:
            break

ans = sum(A)
print(ans)


### FIXED CODE ###

from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [(A[i], 1) for i in range(N)]

changes = [None] * M
for i in range(M):
    b, c = map(int, input().split())
    changes[i] = (c, b)

allVals = A + changes

allVals.sort(key = lambda x:x[0], reverse = True)
# print(allVals)

i = 0
j = -1
res = 0
while True:
    j += 1
    res += allVals[j][0] * allVals[j][1]
    i += allVals[j][1]

    if i >= N:
        res -= allVals[j][0] * (i - N)
        break



print(res)
### BUGGY CODE ###

from collections import Counter

N=int(input())
A=sorted(list(map(int,input().split())))
nmax=10**6
iscop=[True]*(nmax+1)

for a in A:
    if iscop[a]==False:
        continue

    for j in range(2,nmax//a+1):
        iscop[j*a]=False

cnt=Counter(A)
ans=0
for k,v in cnt.items():
    if iscop[k] and v<2:
        ans+=1

print(ans)

### FIXED CODE ###

from collections import Counter

N=int(input())
A=Counter(list(map(int,input().split())))
nmax=10**6
iscop=[True]*(nmax+1)

for k in A.keys():
    if iscop[k]==False:
        continue

    for j in range(2,nmax//k+1):
        iscop[k*j]=False
ans=0
for k,v in A.items():
    if v<2 and iscop[k]:
        ans+=1

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

N = int(input())
*A,=map(int,input().split())
A = sorted(A)

if N == 1:
  print(1)
  exit()

flag=[1]*N
for i in range(N-1):
  if flag[i]==0:continue
  for j in range(i+1,N):
    if flag[j]==0:continue
    if j==i+1 and A[j]==A[i]:
      flag[i] = 0
    if A[j]%A[i] == 0:
      flag[j] = 0
      
print(sum(flag))

### FIXED CODE ###

N = int(input())
*A,=map(int,input().split())
A = sorted(A)

if N == 1:
  print(1)
  exit()

flag = [0]*(10**6+5)
for i in range(N):
  flag[A[i]] = 1

for i in range(N):
  if flag[A[i]] == 0:
    continue
  if i>0 and A[i]==A[i-1]:
    flag[A[i]] = 0
    continue
  for num in range(A[i]*2,A[-1]+1,A[i]):
    flag[num] = 0
  
print(sum(flag))
### BUGGY CODE ###

H,W = map(int,input().split())
S = [input() for i in range(H)]

T = [[0]*W for i in range(H)]
L = [[0]*W for i in range(H)]
for w in range(W):
    a = 0
    cnt = 0
    for h in range(H):
        if S[h][w]==".":
            cnt+=1
        else:
            for ha in range(a,h):
                T[ha][w]=cnt
            a = h+1
            cnt = 0
    if cnt!=0:
        for ha in range(a,H):
            T[ha][w]=cnt
for h in range(H):
    a = 0
    cnt = 0
    for w in range(W):
        if S[h][w]==".":cnt+=1
        else:
            for wa in range(a,w):
                L[h][wa]=cnt
            a = w+1
            cnt = 0
    if cnt!=0:
        for wa in range(a,W):
            L[h][wa]=cnt

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans,T[h][w]+L[h][w]-1)
print(ans)

### FIXED CODE ###

H,W = map(int,input().split())
S = [input() for i in range(H)]

L = [[0]*W for i in range(H)]
R = [[0]*W for i in range(H)]
U = [[0]*W for i in range(H)]
D = [[0]*W for i in range(H)]
for h in range(H):
    for w in range(W):
        if S[h][w]==".":
            if h==0:D[h][w]=1
            else:D[h][w]=D[h-1][w]+1
            if w==0:R[h][w]=1
            else:R[h][w]=R[h][w-1]+1
for h in range(H-1,-1,-1):
    for w in range(W-1,-1,-1):
        if S[h][w]==".":
            if h==H-1:U[h][w]=1
            else:U[h][w]=U[h+1][w]+1
            if w==W-1:L[h][w]=1
            else:L[h][w]=L[h][w+1]+1

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans,L[h][w]+R[h][w]+U[h][w]+D[h][w]-3)
print(ans)
### BUGGY CODE ###

def main():
    import sys
    sys.setrecursionlimit(10**6)
    mod = 10**9+7
    
    fact = [1,1]
    finv = [1,1]
    inv = [0,1]
    
    for i in range(2,2*10**5+5):
        fact.append((fact[-1]*i)%mod)
        inv.append((inv[mod%i]*(mod-mod//i))%mod)
        finv.append((finv[-1]*inv[-1])%mod)
    
    def nCr(n,r,mod):
        
        return fact[n]*finv[r]*finv[n-r]%mod

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

    numl = [0]*n
    resl = [0]*n
    def dfs(x,pre):
        num = 0
        res = 1
        for nex in e[x]:
            if nex == pre:
                continue
            dfs(nex,x)
            num += numl[nex]
            res *= nCr(num,numl[nex],mod)*resl[nex]
            res %= mod
        numl[x] = num+1
        resl[x] = res

        return 

    dfs(0,-1)

    ans = [0]*n
    ans[0] = resl[0]
    def dfs2(x,pre):
        
        for nex in e[x]:
            if nex == pre:
                continue
            pres = [resl[x], numl[x], resl[nex], numl[nex]]
            resl[x] *= pow(nCr(numl[x]-1,numl[nex],mod)*resl[nex],mod-2,mod)
            resl[x] %= mod
            numl[x] -= numl[nex]
            resl[nex] *=  nCr(numl[x]+numl[nex]-1,numl[x],mod)*resl[x]
            resl[nex] %= mod
            numl[nex] += numl[x]
            ans[nex] = resl[nex]
            dfs2(nex,x)
            resl[x], numl[x], resl[nex], numl[nex] = pres
        return
    dfs2(0,-1)
    print(*ans,sep="\n")
if __name__ == "__main__":
    main()

### FIXED CODE ###


import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
mod = 10**9+7
 
fact = [1,1]
finv = [1,1]
inv = [0,1]
 
for i in range(2,2*10**5+5):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)
 
def nCr(n,r,mod):
      
    return (fact[n]*finv[r])%mod*finv[n-r]%mod

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

numl = [0]*n
resl = [0]*n
def dfs(x,pre):
    num = 0
    res = 1
    for nex in e[x]:
        if nex == pre:
            continue
        dfs(nex,x)
        num += numl[nex]
        res *= nCr(num,numl[nex],mod)*resl[nex]
        res %= mod
    numl[x] = num+1
    resl[x] = res

    return 

dfs(0,-1)

ans = [0]*n
ans[0] = resl[0]
def dfs2(x,pre):
    
    for nex in e[x]:
        if nex == pre:
            continue
        pres = [resl[x], numl[x], resl[nex], numl[nex]]
        resl[x] *= pow(nCr(numl[x]-1,numl[nex],mod)*resl[nex],mod-2,mod)
        resl[x] %= mod
        numl[x] -= numl[nex]
        resl[nex] *=  nCr(numl[x]+numl[nex]-1,numl[x],mod)*resl[x]
        resl[nex] %= mod
        numl[nex] += numl[x]
        ans[nex] = resl[nex]
        dfs2(nex,x)
        resl[x], numl[x], resl[nex], numl[nex] = pres
    return
dfs2(0,-1)
for i in ans:
    print(i)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
max_A=max(A)
l=[]
dx=0

for i in A:
    l.append(i)
    if i==max(l):
        dx+=0
    else:
        dx+=abs(max(l)-i)    
print(dx)      

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
x=0
dx=0
for i in A:
    if i>x:
        x=i
    else:
        dx+=(x-i)
print(dx)
### BUGGY CODE ###

X=int(input())
for i in range(-1500,1501):
    for j in range(-1500,1501):
        if (i**5)-(j**5)==X:
            print(i,j)
            exit()


### FIXED CODE ###

X=int(input())
for i in range(-1000,1001):
    for j in range(-1000,1001):
        if (i**5)-(j**5)==X:
            print(i,j)
            exit()
### BUGGY CODE ###

import collections

N = int(input())
listA = list(map(int, input().split()))
# 各数字の出現回数をカウント
countA = dict(collections.Counter(listA).most_common())
countA_calc = {}
countA_calc2 = {}
for i in listA:
    count = 0
    for x, y in countA.items():
        if x == i:
            if x not in countA_calc2:
                countA_calc2[x] = (y -1) * (y - 2) // 2
            count += countA_calc2[x]
        else:
            if x not in countA_calc:
                countA_calc[x] = y * (y -1) // 2 
            count += countA_calc[x]
    print(count)

### FIXED CODE ###

import collections
import math
def combination(a, b):
    tmp = 1
    for i in range(a - b + 1, a + 1):
        tmp *= i
    return tmp // math.factorial(b)
 
N = int(input())
listA = list(map(int, input().split()))
# 各数字の出現回数をカウント
countA = dict(collections.Counter(listA).most_common())
countA_calc = {k: v * (v -1) // 2 for (k, v) in countA.items()}
countA_calc2 = {k: (v - 1) * (v -2) // 2 for (k, v) in countA.items()}
summery = sum(countA_calc.values())
for i in listA:
    print(summery - countA_calc[i] + countA_calc2[i])
### BUGGY CODE ###

from math import gcd
from itertools import zip_longest

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

npcf = False
while True:
    B = []
    for x, y in zip_longest(A[:len(A)//2], A[len(A)//2:], fillvalue=1):
        if gcd(x, y) != 1:
            npcf = True
            break
        B.append(x*y)
    if len(B) == 1:
        break
    A = B

if not npcf:
    print('pairwise coprime')
    exit()

buf = A[0]
for a in A[1:]:
    buf = gcd(buf, a)
if buf == 1:
    print('setwise coprime')
else:
    print('not coprime')

### FIXED CODE ###

from math import gcd

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

prime = list(range(max(A) + 1))

for i in range(2, len(prime)):
    if prime[i] != i:
        continue
    for j in range(i, len(prime), i):
        if prime[j] != j:
            continue
        prime[j] = i

used = set()
pc = True
for a in A:
    used_this = set()
    while a != 1:
        div = prime[a]
        if div in used:
            pc = False
            break
        used_this.add(div)
        a //= div
    used.update(used_this)

if pc:
    print('pairwise coprime')
    exit()

buf = A[0]
for a in A[1:]:
    buf = gcd(buf, a)
if buf == 1:
    print('setwise coprime')
else:
    print('not coprime')
### BUGGY CODE ###

#coding:utf-8
def Lun(k):
	str_k=str(k)
	check=True
	if len(str_k)==1:
		return check
		
	for i in range(len(str_k)-1):
		if (int(str_k[i])+1)>=int(str_k[i+1])>=(int(str_k[i])-1):
			check=True
		else:
			check=False
			return check
	return check
K=int(input())
cnt=1
cnt_L=0
L=0
while True:
	if Lun(cnt):
		cnt_L+=1
		if cnt_L==K:
			L=cnt
			break
	cnt+=1

print(L)


### FIXED CODE ###

#coding:utf-8
from collections import deque
K=int(input())
L=deque([1,2,3,4,5,6,7,8,9])
cnt=0
x=0
for _ in range(K):
	cnt+=1
	x=L.popleft()
	if x%10 !=0:
		L.append(10*x+x%10-1)
	L.append(10*x+x%10)
	if x%10!=9:
		L.append(10*x+x%10+1)

print(x)
### BUGGY CODE ###

from collections import Counter


S = input()
N = len(S)

L = [0] * (N + 1)
s = 0
for i in range(N):
    s += int(S[N - 1 - i]) * pow(10, i)
    L[i + 1] = (s % 2019)

C = Counter(L)
cnt = 0
for key in list(C.keys()):
    k = C[key]
    cnt += (k * (k - 1)) // 2

print(cnt)


### FIXED CODE ###

from collections import Counter


S = input()
N = len(S)

L = [0] * (N + 1)
s = 0
for i in range(N):
    s += int(S[N - 1 - i]) * pow(10, i, 2019)
    L[i + 1] = (s % 2019)

C = Counter(L)
cnt = 0
for key in list(C.keys()):
    k = C[key]
    cnt += (k * (k - 1)) // 2

print(cnt)
### BUGGY CODE ###

a,b,c,d,e,f=map(int,input().split())
INF=10**3

total=0
s=0
max=0
for w in range(31):
    for x in range(31):
        for y in range(101):
            for z in range(101):
                water=100*(w*a+x*b)
                sugar=y*c+z*d
                if water==0:
                    m=INF
                else:
                    m=(sugar/water)*100
                if water+sugar<=f and m<=e:
                    n=100*sugar/(water+sugar)
                    if n>max:
                        max=n
                        total=sugar+water
                        s=sugar
print(total,s)

### FIXED CODE ###

a,b,c,d,e,f=map(int,input().split())
w=set()
for x in range(0,f+1,100*a):
    for y in range(0,f+1-x,100*b):
        w.add(x+y)
s=set()
for x in range(0,f+1,c):
    for y in range(0,f+1-x,d):
        s.add(x+y)

max=-1
total=0
sugar=0
for x in w:
    for y in s:
        if 0<x+y<=f and y<=x*e//100:
            if max<y/(x+y):
                total=x+y
                sugar=y
                max=y/(x+y)
print(total,sugar)
### BUGGY CODE ###

from collections import deque
import sys

H, W = map(int, input().split())
m = [["#"] * (W+2)] + [["#"] + list(input()) + ["#"] for _ in range(H)] + [["#"] * (W+2)]
q = deque()
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

step = [[float("inf") for _ in range(W+2)] for _ in range(H+2)]

for h in range(1, H+1):
	for w in range(1, W+1):
		if m[h][w] == "#":
			q.appendleft([h, w])
			step[h][w] = 0

while q:
	label = q.pop()

	for i in range(4):
		h, w = label[0] + dx[i], label[1] + dy[i]
		if m[h][w] != "#" and step[h][w] > step[label[0]][label[1]] + 1:
			q.appendleft([h, w])
			step[h][w] = step[label[0]][label[1]] + 1

ans = 0
for h in range(1, H+1):
	for w in range(1, W+1):
		ans = max(ans, step[h][w])
print(ans)

### FIXED CODE ###

from collections import deque
import sys
def input():
	return sys.stdin.readline()[:-1]

H, W = map(int, input().split())
m = [["#"] * (W+2)] + [["#"] + list(input()) + ["#"] for _ in range(H)] + [["#"] * (W+2)]
q = deque()
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

step = [[float("inf") for _ in range(W+2)] for _ in range(H+2)]

for h in range(1, H+1):
	for w in range(1, W+1):
		if m[h][w] == "#":
			q.appendleft([h, w])
			step[h][w] = 0

while q:
	label = q.pop()

	for i in range(4):
		h, w = label[0] + dx[i], label[1] + dy[i]
		if m[h][w] != "#" and step[h][w] > step[label[0]][label[1]] + 1:
			q.appendleft([h, w])
			step[h][w] = step[label[0]][label[1]] + 1

ans = 0
for h in range(1, H+1):
	for w in range(1, W+1):
		ans = max(ans, step[h][w])
print(ans)
### BUGGY CODE ###

from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]

def G(_a, _b):
  if _a>=_b:
    a, b = _a, _b
  else:
    a, b = _b, _a
  
  while True:
    c = a%b
    if c == 0:
      break
    a,b = b,c
  
  return b
L=A
while True:
  if len(L)==1:
    ans = L[0]
    break
  elif min(L)==1:
    ans = 1
    break
  else:
    g = G(L[-2], L[-1])
    L[-2] = g
    L.pop()
    
print(ans)
    

### FIXED CODE ###

from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]

def G(_a, _b):
  if _a>=_b:
    a, b = _a, _b
  else:
    a, b = _b, _a
  
  while True:
    c = a%b
    if c == 0:
      break
    a,b = b,c
  
  return b

L = np.array(list(set(A)))
mini = np.min(L)
yaku = [1]
i=2
r_mini = np.sqrt(mini)
while i<=r_mini:
  if mini%i==0:
    yaku.append(i)
  i+=1
yaku2 = list(map(lambda x: int(mini/x), yaku))
yaku = yaku[::-1]
yaku2.extend(yaku)
for y in yaku2:
  if np.sum(L%y)==0:
    ans = y
    break

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

N = int(input())
a = []
for i in range(0, N):
  a.append(int(input()))

first_max = 0
latter_max = max(a[1:])

for i in range(0, N - 1):
  if i > 0:
    first_max = max(first_max, a[i-1])
  if latter_max == a[i]:
    latter_max = max(a[i+1:])
  print(max(first_max, latter_max))

print(max(a[:-1]))

### FIXED CODE ###

N = int(input())
a = []
for i in range(0, N):
  a.append(int(input()))

first_max = max(a)

former_arr = [0] + a[0:a.index(first_max)]
latter_arr = [0] + a[a.index(first_max) + 1:]
second_max = (max(max(former_arr), max(latter_arr)))

ans = ""
ans += (str(first_max) + '\n') * (a.index(first_max))
ans += (str(second_max) + '\n')
ans += (str(first_max) + '\n') * (N - a.index(first_max) - 1)
print(ans.rstrip('\n'))
### BUGGY CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-



import numpy as np


H, W, D = map(int, input().split())

A = []

for i in range(H):
    A.append(list(map(int, input().split())))

A = np.array(A)

Q = int(input())

for i in range(Q):
    L, R = map(int, input().split())
    cost = 0
    while L != R:
        start = np.where(A==L)
        stop  = np.where(A==L+D)
        cost += abs(start[0][0] - stop[0][0]) + abs(abs(start[1][0] - stop[1][0]))
        L += D
    print(cost, flush=True)


### FIXED CODE ###

# speed-test
# https://abc089.contest.atcoder.jp/submissions/2206669

h,w,d = map(int,input().split())
 
dic = {}
for i in range(h):
    a = input().split()
    for j in range(w):
        dic[int(a[j])] = (i+1,j+1)
        
q = int(input())
c = [0]*(h*w+1)
for i in range(d+1,h*w+1):
    pi,pj = dic[i]; qi,qj = dic[i-d]
    c[i] = c[i-d] + abs(pi-qi) + abs(pj-qj)
    
for i in range(q):
    l,r = map(int,input().split())
    print(c[r]-c[l])
### BUGGY CODE ###

from bisect import bisect_left

N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]

t = [[] for _ in range(N)]

ans = 0
for i in range(N):
    for j in range(len(t)-1, -1, -1):
        idx = bisect_left(t[j], A[i])
        if idx != len(t[j]):
            if abs(t[j][idx] - A[i]) <= K:
                t[j+1].append(A[i])
                ans = max(ans, j+2)
                break
        elif idx > 0:
            if abs(t[j][idx-1] -A[i]) <= K:
                t[j+1].append(A[i])
                ans = max(ans, j+2)
                break
    else:
        t[0].append(A[i])
        ans = max(ans, 1)

print(ans)

### FIXED CODE ###

from bisect import bisect_left

N, K = map(int, input().split())
A = [int(input()) for _ in range(N)]

t = [[] for _ in range(N)]

ans = 0
for i in range(N):
    for j in range(ans-1, -1, -1):
        idx = bisect_left(t[j], A[i])
        if idx != len(t[j]):
            if abs(t[j][idx] - A[i]) <= K:
                t[j + 1].insert(bisect_left(t[j + 1], A[i]), A[i])
                ans = max(ans, j+2)
                break
        if idx > 0:
            if abs(t[j][idx-1] - A[i]) <= K:
                t[j + 1].insert(bisect_left(t[j + 1], A[i]), A[i])
                ans = max(ans, j+2)
                break
    else:
        t[0].insert(bisect_left(t[0], A[i]), A[i])
        ans = max(ans, 1)

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

from fractions import gcd
def gcd(a,b):
  r = a%b
  while r > 0:
    a=b
    b=r
    r=a%b
  return b

n = int(input())
A = list(map(int,input().split()))
num = 1
ans = 0
for i in A:
  num = i // gcd(i,num) * num

for i in A:
  ans += num//i
  ans %= 1000000007
  
print(int(ans))

### FIXED CODE ###

from fractions import gcd


n = int(input())
A = list(map(int,input().split()))
num = 1
ans = 0
for i in A:
  num = i // gcd(i,num) * num

for i in A:
  ans += num//i
  
print(int(ans%1000000007))
### BUGGY CODE ###

import sys
readline = sys.stdin.readline

N =  int(readline())
HP = [tuple(map(int, readline().split())) for _ in range(N)]
HP.sort(key = sum)
INF = 10**18+3

dp = [0]
for i in range(N):
    hi, pi = HP[i]
    dp2 = dp[:] + [INF]
    for j in range(i+1):
        if dp[j] > hi:
            break
        dp2[j+1] = min(dp2[j+1], dp[j]+pi)

    dp = dp2[:]

for ans in range(N+1):
    if dp[ans] == INF:
        ans -= 1
        break
print(ans)



### FIXED CODE ###

import sys
readline = sys.stdin.readline

N =  int(readline())
HP = [tuple(map(int, readline().split())) for _ in range(N)]
HP.sort(key = lambda x: x[0] + x[1])
INF = 1<<64

dp = [0]
for i in range(N):
    hi, pi = HP[i]
    dp += [INF]
    for j in range(i+1, 0, -1):
        if dp[j-1] > hi:
            continue
        dp[j] = min(dp[j], dp[j-1]+pi)
for ans in range(N+1):
    if dp[ans] == INF:
        ans -= 1
        break
print(ans)
### BUGGY CODE ###

import sys
from collections import deque
sys.setrecursionlimit(1000000)

h, w = map(int, input().split())
route = [[] for j in range(w * h)]
prev = []
somes = 0
for e in range(h):
    a = list(input())
    for g in a:
        if g == ".":
            somes += 1
    for l in range(w - 1):
        if a[l:l+2] == [".", "."]:
            route[e*w + l].append(e*w + l + 1)
            route[e * w + l + 1].append(e * w + l)
    if not prev:
        prev = a
        continue
    for l in range(len(a)):
        if a[l] == prev[l] == ".":
            route[e*w + l].append(e*w+l-w)
            route[e * w + l - w].append(e * w + l)
    prev = a
start = 0
goal = h*w-1
routes = []
eachmin = [float("inf") for i in range(h*w)]
eachmin[0] = 0
queue = deque([start])
searched = []
def bfs(time = 0):
    global searched, queue

    while queue:
        now = queue.popleft()

        if now == goal:
            break

        for j in route[now]:
            if j not in searched:
                queue.append(j)
                eachmin[j] = eachmin[now] + 1
        searched.append(now)

bfs(start)
if eachmin[-1] > 500000:
    print("-1")
    exit()
print(somes - eachmin[-1] - 1)

### FIXED CODE ###

import sys
from collections import deque
sys.setrecursionlimit(1000000)

h, w = map(int, input().split())
route = [[] for j in range(w * h)]
prev = []
somes = 0
for e in range(h):
    a = list(input())
    for g in a:
        if g == ".":
            somes += 1
    for l in range(w - 1):
        if a[l:l+2] == [".", "."]:
            route[e*w + l].append(e*w + l + 1)
            route[e * w + l + 1].append(e * w + l)
    if not prev:
        prev = a
        continue
    for l in range(len(a)):
        if a[l] == prev[l] == ".":
            route[e*w + l].append(e*w+l-w)
            route[e * w + l - w].append(e * w + l)
    prev = a
start = 0
goal = h*w-1
routes = []
eachmin = [float("inf") for i in range(h*w)]
eachmin[0] = 0
queue = deque([start])
searched = []
def bfs(time = 0):
    global searched, queue

    while queue:
        now = queue.popleft()
        if now in searched:
            continue
        if now == goal:
            break

        for j in route[now]:
            if j not in searched:
                queue.append(j)
                eachmin[j] = eachmin[now] + 1
        searched.append(now)

bfs(start)
if eachmin[-1] > 500000:
    print("-1")
    exit()
print(somes - eachmin[-1] - 1)