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

import numpy as np
n,ma,mb = map(int, input().split())
a,b,c = [],[],[]
for i in range(n):
    ia,ib,ic = map(int, input().split())
    a.append(ia)
    b.append(ib)
    c.append(ic)
sa = sum(a)
sb = sum(b)
INF = 10**5
dp = np.full((n+1,sa+1,sb+1), INF, dtype=int)
dp[0][0][0] = 0

for i in range(n):
    for ca in range(sa):
        for cb in range(sb):
            if dp[i][ca][cb] == INF:
                continue
            dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb])
            dp[i+1][ca+a[i]][cb+b[i]] = min(dp[i+1][ca+a[i]][cb+b[i]], dp[i][ca][cb] + c[i])



res = INF
for ca in range(1, sa):
    for cb in range(1, sb):
        if ca*mb==cb*ma:
            res = min(res, dp[n][ca][cb])

if res == INF:
    res = -1
print(res)


### FIXED CODE ###

def main():
    n,ma,mb = map(int, input().split())
    a,b,c = [],[],[]
    for i in range(n):
        ia,ib,ic = map(int, input().split())
        a.append(ia)
        b.append(ib)
        c.append(ic)
    sa = sum(a)
    sb = sum(b)
    INF = 10**5
    dp = [[ [INF] * (sb+1) for i in range(sa+1)] for i in range(n+1)]
    dp[0][0][0] = 0

    for i in range(n):
        for ca in range(sa):
            for cb in range(sb):
                if dp[i][ca][cb] == INF:
                    continue
                dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb])
                dp[i+1][ca+a[i]][cb+b[i]] = min(dp[i+1][ca+a[i]][cb+b[i]], dp[i][ca][cb] + c[i])



    res = INF
    for ca in range(1, sa):
        for cb in range(1, sb):
            if ca*mb==cb*ma:
                res = min(res, dp[n][ca][cb])

    if res == INF:
        res = -1
    print(res)

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

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

l = ""
flag = True
count = 0
while True:
    if flag == True:
        for x in range(a):
            l += "b"
        flag = False
    else:
        for y in range(b):
            l += "r"
        flag = True

    if len(l) >= n:
        for c in range(n):
            if l[c] == "b":
                count += 1
        break

print(count)


### FIXED CODE ###

N, A, B = map(int, input().split())
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)
### BUGGY CODE ###

import itertools as it
def charge(price,payment):
    val =[0,0,0,0]
    coins = [500,100,50,10]
    rem = payment - price
    for i in range(4):
        val[i] =rem //coins[i]
        rem = rem%coins[i]
    return sum(val)
count =0
while 1:
    price = int(input())
    if price ==0:break
    if count !=0:print(' ')
    max10,max50,max100,max500 = list(map(int,input().split(' ')))
    ans = (max10,max50,max100,max500)
    mincharge = max10+max50+max100+max500
    temp10 = [i for i in range(max10+1)]
    temp50 = [i for i in range(max50+1)]
    temp100 = [i for i in range(max100+1)]
    temp500 = [i for i in range(max500+1)]
    combinations = list(it.product(temp10,temp50,temp100,temp500))
    for com in combinations:
        pay= com[0]*10+com[1]*50+com[2]*100+com[3]*500
        if price> pay:continue
        temp = charge(price,pay)
        if mincharge > temp:
            mincharge = temp
            ans = com
    p = [10,50,100,500]
    for i in range(4):
        if ans[i] !=0:print("{} {}".format(p[i],ans[i]))
    count+=1


### FIXED CODE ###

count = 0
coins =[10,50,100,500]
while 1:
    price = int(input())
    if price ==0:break
    if count !=0:print('')
    wallet= list(map(int,input().split(' ')))
    cash = wallet[0]* 10 + wallet[1] * 50 + wallet[2] * 100 + wallet[3] * 500
    charge = cash - price
    chargecoins = ((charge % 50) // 10,(charge % 100)//50,(charge % 500)//100,charge // 500)
    for  i in range(4):
        if wallet[i] > chargecoins[i]:print('{} {}'.format(coins[i],wallet[i]-chargecoins[i]))
    count +=1
### BUGGY CODE ###

s,K = open(0).read().split()
K = int(K)
ss = set()
temp = set([''])
for x in s:
    temp = set([''.join((y,x)) for y in temp])
    ss = ss | temp
    temp.add('')
l = sorted(ss)
print(l[K-1])

### FIXED CODE ###

s,K = open(0).read().split()
K = int(K)
ss = set()
temp = set([''])
for x in s:
    temp = set([''.join((y,x)) for y in temp if len(y) <= 4])
    ss = ss | temp
    temp.add('')
l = list(ss)
l.sort()
print(l[K-1])
### BUGGY CODE ###

N=int(input())
l=[]
for x in range(0,N):
    l.append(input())
A=[[0 for i in range(10)] for j in range(N)]
B=[[0 for i in range(10)] for j in range(N)]
for i in range(0,N):
    for j in range(0,10):
        if l[i][j]=='a':
            A[i][j]=0
        elif l[i][j]=='b':
            A[i][j]=1
        elif l[i][j]=='c':
            A[i][j]=2
        elif l[i][j]=='d':
            A[i][j]=3
        elif l[i][j]=='e':
            A[i][j]=4
        elif l[i][j]=='f':
            A[i][j]=5
        elif l[i][j]=='g':
            A[i][j]=6
        elif l[i][j]=='h':
            A[i][j]=7
        elif l[i][j]=='i':
            A[i][j]=8
        elif l[i][j]=='j':
            A[i][j]=9
        elif l[i][j]=='k':
            A[i][j]=10
        elif l[i][j]=='l':
            A[i][j]=11
        elif l[i][j]=='m':
            A[i][j]=12
        elif l[i][j]=='n':
            A[i][j]=13
        elif l[i][j]=='o':
            A[i][j]=14
        elif l[i][j]=='p':
            A[i][j]=15
        elif l[i][j]=='q':
            A[i][j]=16
        elif l[i][j]=='r':
            A[i][j]=17
        elif l[i][j]=='s':
            A[i][j]=18
        elif l[i][j]=='t':
            A[i][j]=19
        elif l[i][j]=='u':
            A[i][j]=20
        elif l[i][j]=='v':
            A[i][j]=21
        elif l[i][j]=='w':
            A[i][j]=22
        elif l[i][j]=='x':
            A[i][j]=23
        elif l[i][j]=='y':
            A[i][j]=24
        else:
            A[i][j]=25
    B[i]=sorted(A[i])
ans=0
for i in range(0,N):
    for j in range(i+1,N):
        if B[i]==B[j]:
            ans=ans+1
print(ans)


### FIXED CODE ###

N=int(input())
l=[]
for x in range(0,N):
    l.append(input())
for x in range(N):
    k=list(l[x])
    k.sort()
    k=''.join(k)
    l[x]=k
l.sort()
k=1
ans=0
for i in range(N-1):
    if l[i]==l[i+1]:
        k+=1
    else:
        ans+=k*(k-1)//2
        k=1
ans+=k*(k-1)//2
print(ans)
### BUGGY CODE ###

from heapq import heappush,heappop
import sys
input=sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
lst=[]
for i in range(N):
    heappush(lst,[-B[i],i])

count=0
while lst:
    h,i=heappop(lst)
    h=-h
    x,z=B[i-1],B[(i+1)%N]
    if (h-A[i])%(x+z)==0:
        num=(h-A[i])//(x+z)
        count+=num
        B[i]=A[i]
        continue
    else:
        num=h//(x+z)
        h=h%(x+z)
        count+=num
        if num==0:
            print(-1)
            sys.exit()
        B[i]=h    
        if A[i]>h:
            print(-1)
            sys.exit()
        heappush(lst,[-h,i])

if A==B:
    print(count)
else:
    print(-1)

### FIXED CODE ###

from heapq import heappush,heappop
import sys
input=sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
lst=[]
for i in range(N):
    heappush(lst,(-B[i],i))

count=0
while lst:
    h,i=heappop(lst)
    h=-h
    x,z=B[i-1],B[(i+1)%N]
    kkk=x+z
    if (h-A[i])%kkk==0:
        count+=(h-A[i])//kkk
        B[i]=A[i]
        continue
    elif kkk>=h:
        print(-1)
        sys.exit()
    else:
        count+=h//kkk
        h=h%kkk
        B[i]=h    
        if A[i]>h:
            print(-1)
            sys.exit()
        heappush(lst,(-h,i))

if A==B:
    print(count)
else:
    print(-1)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
c=0
for i in set(a):
  n=a.count(i)
  c+=n if n<i else n-i
print(c)


### FIXED CODE ###

from collections import Counter
a = int(input())
l = list(map(int, input().split()))
#i = 1

c=Counter(l)
d = dict(c)
kv = []
for k,v in d.items():
    if k>v:
        kv.append(v)
    elif k<v:
        t = v-k
        kv.append(t)
s = sum(kv)
print(s)
### BUGGY CODE ###

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

a = [0] * (N + 1)
r = [0] * P

if P != 2 and P != 5:
    tenfactor=1
    for i in range(1,N+1):
        a[i] = (int(S[N-i])*tenfactor+a[i-1])
        tenfactor*=10
        r[a[i] % P] += 1
    r[0] += 1
    ans = 0
    from collections import Counter
    C=Counter(r)
    for v,i in C.items():
        ans += (v * (v - 1) // 2)*i
elif P == 2:
    ans = 0
    for i in range(N):
        if int(S[i]) % 2 == 0:
            ans += i + 1
elif P == 5:
    ans = 0
    for i in range(N):
        if int(S[i]) == 0 or int(S[i]) == 5:
            ans += i + 1

print(ans)



### FIXED CODE ###

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

a = [0] * (N + 1)

if P != 2 and P != 5:
    tenfactor=1
    for i in range(1,N+1):
        a[i] = ((int(S[N-i])*tenfactor+a[i-1])%P)
        tenfactor*=10
        tenfactor%=P

    ans = 0
    from collections import Counter
    C=Counter(a)
    for v,i in C.items():
        ans += (i * (i - 1) // 2)
elif P == 2:
    ans = 0
    for i in range(N):
        if int(S[i]) % 2 == 0:
            ans += i + 1
elif P == 5:
    ans = 0
    for i in range(N):
        if int(S[i]) == 0 or int(S[i]) == 5:
            ans += i + 1

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

N,P =map(int,input().split(' '))
if N==1:
    print(P)
    exit()
for i in range(int(pow(P,1/N)+1),0,-1):
    if P%pow(i,N)==0:
        print(i)
        break

### FIXED CODE ###

from collections import Counter
N,P =map(int,input().split(' '))
if N==1:
    print(P)
    exit()
prime = []
f = 2
while f**2 <=P:
    if P%f==0:
        prime.append(f)
        P//=f
    else:
        f += 1
if P != 1:
    prime.append(f)

ans = 1
for k,v in Counter(prime).items():
    if v//N:
        ans *= k**(v//N)
print(ans)
### BUGGY CODE ###

def main():
    z = input()
    x = int(z)

    sum = 0
    while x > 0:
        y = x % 10
        sum = sum + y
        x = x // 10

    if sum%9==0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    z = input()
    x = int(z)

    if x%9==0:
        print('Yes')
    else:
        print('No')

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

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

dp = [float('inf') for _ in range(len(h))]
dp[0] = 0

for i in range(len(dp)):
    for j in range(max(i - K, 0), i):
        dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]))

print(dp[-1])


### FIXED CODE ###

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

dp = [float('inf') for _ in range(len(h))]
dp[0] = 0

for i in range(len(dp)):
    for j in range(max(i - K, 0), i):
        dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]))

print(dp[-1])
### BUGGY CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
n = int(input())
A = []
ans = 0
adjacent_list = [[] for i in range((n + 2) * n)]
for i in range(n):
    tmp = list(map(int, input().split()))
    pre = tmp[0] - 1
    for j in range(1, len(tmp)):
        l, g = min(i, tmp[j] - 1), max(i, tmp[j] - 1 )
        pre_l, pre_g = min(i, pre), max(i, pre) 
        adjacent_list[pre_l * n + pre_g].append(l * n + g)
        pre = tmp[j] - 1
not_candidate = set([])
for i in range((n + 2) * n):
    if len(adjacent_list[i]) == 0:
        not_candidate.add(i)
        continue
    for j in adjacent_list[j]:
        not_candidate.add(j)
#まず、閉路検
seen = [False for i in range((n + 2) * n)]
visited = [False for i in range((n + 2) * n)]
def check(node):
    seen[node] = True
    for i in adjacent_list[node]:
        if seen[i] and (not visited[i]):
            print(-1)
            exit()
        check(i)
    visited[node] = True
def dfs_path(node):
    if len(adjacent_list[node]) == 0:
        return 1
    if node in finish:
        return finish[node]
    tmp = 0
    for i in adjacent_list[node]:
        tmp = max(tmp, dfs_path(i) + 1)
    finish[node] = max(tmp, finish[node])
    return finish[node]
finished = set()
for i in range((n + 2) * n):
    check(i)
finish = defaultdict(int)
for i in range((n + 2) * n):
    if i not in not_candidate :
        dfs_path(i)
print(max(max(finish.values()), 1))

### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
n = int(input())
A = []
M = [[-1 for _ in range(n)] for _ in range(n)]
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        M[i][j] = cnt
        M[j][i] = cnt
        cnt += 1
ans = 0
nodes = []
adjacent_list = [[] for i in range(n*(n-1)//2)]
for i in range(n):
    tmp = list(map(int, input().split()))
    pre = tmp[0] - 1
    for j in tmp[1:]:
        adjacent_list[M[i][pre]].append(M[i][j-1])
        pre = j - 1
#まず、閉路検
seen = defaultdict(lambda: False)
visited = defaultdict(lambda: False)
def check(node):
    if visited[node]:
        return
    seen[node] = True
    for i in adjacent_list[node]:
        if seen[i] and (not visited[i]):
            print(-1)
            exit()
        check(i)
    visited[node] = True
def dfs_path(node):
    if not adjacent_list[node]:
        return 1
    if finish[node]:
        return finish[node]
    tmp = 0
    for i in adjacent_list[node]:
        tmp = max(tmp, dfs_path(i) + 1)
    finish[node] = tmp
    return finish[node]
finished = set()
finish = [0 for i in range(n*(n-1)//2)]
for i in range(n*(n-1)//2):
    check(i)
    dfs_path(i)
print(max(max(finish), 1))
### BUGGY CODE ###

K,S = map(int,input().split())
count = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            #print(x,y,z)
            if x+y+z==S:
                #print("x =",x,"y =",y,"z =",z)
                count+=1

print(count)



### FIXED CODE ###

K,S = map(int,input().split())
count = 0
for x in range(K+1):
    for y in range(K+1):
       count+=(0<=S-(x+y)<=K)

print(count)
### BUGGY CODE ###

N,K=map(int,input().split())
h=[int(i) for i in input().split()]
dp=[0]
for i in range(1,N):
    dp.append(1000000000)
for i in range(0,N):
    li=[j+i for j in range(1,K+1)]
    #print(li)
    for j in li:
        if(j<N):
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]))
#print(dp)
print(dp[N-1])

### FIXED CODE ###

N,K=map(int,input().split())
h=[int(i) for i in input().split()]
dp=[0]
for i in range(1,N):
    dp.append(1000000000)
for i in range(0,N):
    li=[j+i for j in range(1,K+1)]
    #print(li)
    for j in li:
        if(j<N):
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]))
#print(dp)
print(dp[N-1])
### BUGGY CODE ###

N,P = map(int,input().split())
ans=1
if N==1:
  print(P)
  exit()
elif P==1|N>=40:
  print(1)
  exit()
else:
  i=1
  while i<=P**(1/N):
    count = 0
    while P%i==0:
      P=P//i
      count+=1
    cn=count//N
    ans*=i**cn
    if i==2|i==1:
      i+=1
    else:
      i+=2
print(int(ans))
exit()

### FIXED CODE ###

N,P = map(int,input().split())
i = round(P**(1/N))
res = []
if N == 1:
  print(P)
elif P == 1:
  print(1)
else:
  for i in range(i,0,-1):
    if P%i**N==0:
      print(i)
      break
### BUGGY CODE ###

A, B, K =map(int,input().split())
n = A
for i in range(B-A+1):

  if int(n-A)<K or int(B-n)<K:
    print(n)
  n += 1

### FIXED CODE ###

A, B, K = map(int,input().split())
for i in range(A,min(B,A+K-1)+1,1):
    print(i)
for j in range(max(B-K+1,A+K),B+1,1):
    print(j)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, T: "List[int]", A: "List[int]"):
    tmpT = T[0]
    tmpA = A[0]
    for i in range(1, N):
        d = 1
        while(T[i]*d<tmpT or A[i]*d<tmpA):
            d += 1
        tmpT = T[i] * d
        tmpA = A[i] * d
    print(tmpT+tmpA)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    T = [int()] * (N)  # type: "List[int]" 
    A = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        T[i] = int(next(tokens))
        A[i] = int(next(tokens))
    solve(N, T, A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, T: "List[int]", A: "List[int]"):
    tmpT = 1
    tmpA = 1
    for i in range(N):
        d = max((tmpT-1)//T[i]+1, (tmpA-1)//A[i]+1)
        tmpT = T[i] * d
        tmpA = A[i] * d
    print(tmpT+tmpA)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    T = [int()] * (N)  # type: "List[int]" 
    A = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        T[i] = int(next(tokens))
        A[i] = int(next(tokens))
    solve(N, T, A)

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

from collections import Counter
N = int(input())
A = Counter(list(map(int, input().split(' '))))
ans = 0
for i in A.keys():
    flg = True
    if A[i] > 1:
        continue
    tmp = []
    for j in range(1,int(i**0.5)+2):
        if not i%j:
            if j != i//j:
                tmp.append(i//j)
            tmp.append(j)
    for k in tmp:
        if A[k] and i != k:
            flg = False
            break
    if flg:
        ans += 1
print(ans)

### FIXED CODE ###

from collections import Counter
N = int(input())
A = Counter(list(map(int,input().split(' '))))
ans = 0
m = max(A.keys())
L = [1]*(10**6+1)
for i in sorted(A.keys()):
    if not L[i]:
        continue
    if A[i] == 1:
        ans += 1
    for j in range(i,m+1,i):
        L[j] = 0
print(ans)
### BUGGY CODE ###

import copy

K,N = map(int, input().split())
An = list(map(int, input().split()))
ans = [max(An) - min(An)]
for i in range(len(An)):
    A_list = copy.copy(An)
    A_list[i] = A_list[i]-K
    ans.append(max(A_list) - min(A_list))
print(min(ans))

### FIXED CODE ###

import numpy as np

K,N = map(int, input().split())
An = list(map(int, input().split()))
arr = np.array(An)
arr = np.diff(arr)
ans = list(arr)
ans.append(K-An[-1]+An[0])
# print(ans)
ans.remove(max(ans))
print(sum(ans))
### BUGGY CODE ###

import numpy as np

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

maze_x = [input() for _ in range(H)]
maze_y = [''.join(x) for x in zip(*maze_x)]

def count_light(maze, W, H):
    cnt = [[0]*W for _ in range(H)]
    for hh in range(H):
        lst1 = [i for i in maze[hh].split('#') if i != '']
        lst2 = [i for i in maze[hh].split('.') if i != '']
        
        ww = 0
        k1 = 0
        k2 = 0
        while len(lst1)>k1:
            if maze[hh][ww] == '.':
                ln = len(lst1[k1])
                cnt[hh][ww:ww+ln] = [ln]*ln
                k1 += 1
            else:
                ln = len(lst2[k2])
                cnt[hh][ww:ww+ln] = [0]*ln
                k2 += 1
            ww += ln
    return cnt
cnt = (np.array(count_light(maze_x, W, H)) + np.array(count_light(maze_y, H, W)).T -1)

print(max([max(cnt[i]) for i in range(H)]))

### FIXED CODE ###

import numpy as np

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

maze01 = np.array([[int(x=='.') for x in input()] for _ in range(H)]) 

u = np.zeros((H, W), dtype=np.int32)
d = np.zeros((H, W), dtype=np.int32)
r = np.zeros((H, W), dtype=np.int32)
l= np.zeros((H, W), dtype=np.int32)


u[0] = maze01[0]
d[H - 1] = maze01[H - 1]
for hh in range(1,H):
    u[hh] = u[hh-1] + maze01[hh]
    u[hh] *= maze01[hh]
    d[H - hh - 1] = d[H - hh] + maze01[H - hh - 1]
    d[H - hh - 1] *= maze01[H - hh - 1]

l[:, 0] = maze01[:, 0]
r[:, W - 1] = maze01[:, W - 1]
for ww in range(1, W):
    l[:, ww] = l[:, ww -1] + maze01[:, ww]
    l[:, ww] *= maze01[:, ww]
    r[:, W - ww -1] = r[:, W - ww] + maze01[:, W - ww - 1]
    r[:, W - ww -1] *= maze01[:, W - ww - 1]

cnt = r + l + u + d - 3

print(max([max(cnt[i]) for i in range(H)]))
### BUGGY CODE ###

N, M = map(int, input().split())
a_list = []
dp = [0]*(N+1)
for _ in range(M):
  a = int(input())
  a_list.append(a)

dp[0] = 1
for i in range(1,N+1):
  dp[i] = (dp[i-1] + dp[i-2])%(10**9+7)
  if i in a_list:
    dp[i] = 0
print(dp[N])

### FIXED CODE ###

N, M = map(int, input().split())
a_list = set([int(input()) for i in range(M)])
dp = [0]*(N+1)

dp[0] = 1
for i in range(1,N+1):
  dp[i] = (dp[i-1] + dp[i-2])%(10**9+7)
  if i in a_list:
    dp[i] = 0
print(dp[N])
### BUGGY CODE ###

from fractions import gcd
from functools import reduce

LARGE_INT = 10 ** 9 + 7

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

total = 0
for a in A:
    total += lcm // a % LARGE_INT
    total %= LARGE_INT
print(total)


### FIXED CODE ###

import sys
from fractions import gcd

input = sys.stdin.buffer.readline

LARGE = 10 ** 9 + 7

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

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

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

total = 0
for a in A:
    total += l // a

print(total % LARGE)
### BUGGY CODE ###

import numpy as np
h, w = map(int, input().split())
S = [list(input()) for _ in range(h)]
L = np.zeros((h, w), dtype=int)
for i in range(h):
    for j in range(w):
        if j == 0 and S[i][j] != '#':
            L[i, j] = 1
        elif S[i][j] != '#':
            L[i, j] = L[i, j-1] + 1
R = np.zeros((h, w), dtype=int)
for i in range(h):
    for j in range(w-1, -1, -1):
        if j == w-1 and S[i][j] != '#':
            R[i, j] = 1
        elif S[i][j] != '#':
            R[i, j] = R[i, j+1] + 1
U = np.zeros((h, w), dtype=int)
for j in range(w):
    for i in range(h):
        if i == 0 and S[i][j] != '#':
            U[i, j] = 1
        elif S[i][j] != '#':
            U[i, j] = U[i-1, j] + 1
D = np.zeros((h, w), dtype=int)
for j in range(w):
    for i in range(h-1, -1, -1):
        if i == h-1 and S[i][j] != '#':
            D[i, j] = 1
        elif S[i][j] != '#':
            D[i, j] = D[i+1, j] + 1
ans = -1
for i in range(h):
    for j in range(w):
        ans = max(ans, L[i,j]+R[i,j]+U[i,j]+D[i,j]-3)
print(ans)

### FIXED CODE ###

h, w = map(int, input().split())
S = [list(input()) for _ in range(h)]
L = [[0]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if j == 0 and S[i][j] != '#':
            L[i][j] = 1
        elif S[i][j] != '#':
            L[i][j] = L[i][j-1] + 1
R = [[0]*w for _ in range(h)]
for i in range(h):
    for j in range(w-1, -1, -1):
        if j == w-1 and S[i][j] != '#':
            R[i][j] = 1
        elif S[i][j] != '#':
            R[i][j] = R[i][j+1] + 1
U = [[0]*w for _ in range(h)]
for j in range(w):
    for i in range(h):
        if i == 0 and S[i][j] != '#':
            U[i][j] = 1
        elif S[i][j] != '#':
            U[i][j] = U[i-1][j] + 1
D = [[0]*w for _ in range(h)]
for j in range(w):
    for i in range(h-1, -1, -1):
        if i == h-1 and S[i][j] != '#':
            D[i][j] = 1
        elif S[i][j] != '#':
            D[i][j] = D[i+1][j] + 1
ans = -1
for i in range(h):
    for j in range(w):
        ans = max(ans, L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)
print(ans)