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

import queue
import copy

H,W = map(int,input().split())
c =[]
c.append(['×' for _ in range(W+2)])
ans = []
ans.append([0 for _ in range(W+2)])
q = queue.Queue()
for i in range(H):
    tmp = list('×'+input()+'×')
    ans_tmp = []
    for j in range(W+2):
        if tmp[j] == '#':
            ans_tmp.append(0)
            q.put([j,i+1])
        elif tmp[j] == '×':
            ans_tmp.append(0)
        else:
            ans_tmp.append(10**4)
    c.append(tmp)
    ans.append(ans_tmp)

c.append(['×' for _ in range(W+2)])
ans.append([0 for _ in range(W+2)])


def bfs(q):
    while not q.empty():
        x,y = q.get()
        if c[y][x-1] == '.':
            q.put([x-1,y])
            ans[y][x-1] = ans[y][x] + 1
            c[y][x-1] = '#'
        if c[y][x+1] == '.':
            q.put([x+1,y])
            ans[y][x+1] = ans[y][x] + 1
            c[y][x+1] = '#'
        if c[y-1][x] == '.':
            q.put([x,y-1])
            ans[y-1][x] = ans[y][x] + 1
            c[y-1][x] = '#'
        if c[y+1][x] == '.':
            q.put([x,y+1])
            ans[y+1][x] = ans[y][x] + 1
            c[y+1][x] = '#'

bfs(q)
max_ans = 0
for i in range(H+2):
    #print(ans[i])
    max_ans = max(max_ans,max(ans[i]))

print(max_ans)


### FIXED CODE ###

from subprocess import call
call (('pypy3', '-c', """
from collections import deque

H,W = map(int,input().split())
c =[]
c.append(['×' for _ in range(W+2)])
ans = []
ans.append([0 for _ in range(W+2)])
q = deque()
for i in range(H):
    tmp = list('×'+input()+'×')
    ans_tmp = []
    for j in range(W+2):
        if tmp[j] == '#':
            ans_tmp.append(0)
            q.append([j,i+1])
        elif tmp[j] == '×':
            ans_tmp.append(0)
        else:
            ans_tmp.append(10**4)
    c.append(tmp)
    ans.append(ans_tmp)

c.append(['×' for _ in range(W+2)])
ans.append([0 for _ in range(W+2)])


def bfs(q):
    while q:
        x,y = q.popleft()
        if c[y][x-1] == '.':
            q.append([x-1,y])
            ans[y][x-1] = ans[y][x] + 1
            c[y][x-1] = '#'
        if c[y][x+1] == '.':
            q.append([x+1,y])
            ans[y][x+1] = ans[y][x] + 1
            c[y][x+1] = '#'
        if c[y-1][x] == '.':
            q.append([x,y-1])
            ans[y-1][x] = ans[y][x] + 1
            c[y-1][x] = '#'
        if c[y+1][x] == '.':
            q.append([x,y+1])
            ans[y+1][x] = ans[y][x] + 1
            c[y+1][x] = '#'

bfs(q)
max_ans = 0
for i in range(H+2):
    #print(ans[i])
    max_ans = max(max_ans,max(ans[i]))

print(max_ans)
"""))
### BUGGY CODE ###

import sys
INF = 10 ** 15
MOD = 10 ** 9 + 7
sys.setrecursionlimit(100000000)
input = sys.stdin.readline
from math import pi
from functools import lru_cache

def main():
    n = int(input())
    num = list(map(int,input().split()))
    
    @lru_cache(maxsize = None)
    def dfs(i,a,b,c):
        if i == n:
            return 1
        ans = 0
        if num[i] == a:
            ans += dfs(i + 1,a + 1,b,c)
            ans %= MOD
        if num[i] == b:
            ans += dfs(i + 1,a,b + 1,c)
            ans %= MOD
        if num[i] == c:
            ans += dfs(i + 1,a,b,c + 1)
            ans %= MOD
        return ans
    
    print(dfs(0,0,0,0))

if __name__ =='__main__':
    main()   

### FIXED CODE ###

MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

ans = 1
def dfs(i,x,y,z,a,n):
    global ans
    if i == n:
        return
    if x == y == z == a[i]:
        ans *= 3
        ans %= MOD
        dfs(i + 1,x + 1,y,z,a,n)
    elif x == y == a[i]:
        ans *= 2
        ans %= MOD
        dfs(i + 1,x + 1,y,z,a,n)
    elif y == z == a[i]:
        ans *= 2
        ans %= MOD
        dfs(i + 1,x,y + 1,z,a,n)
    elif x == a[i]:
        dfs(i + 1,x + 1,y,z,a,n)
    elif y == a[i]:
        dfs(i + 1,x,y + 1,z,a,n)
    elif z == a[i]:
        dfs(i + 1,x,y,z + 1,a,n)
    else:
        ans = 0
        return

def main():
    n = int(input())
    a = list(map(int,input().split()))

    dfs(0,0,0,0,a,n)
    print(ans)

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

import numpy as np
N, M = map(int,input().split())
arr = np.array([list(map(int,input().split())) for x in range(N)])

xsort = arr[np.argsort(arr[:,0])]
ysort = arr[np.argsort(arr[:,1])]
zsort = arr[np.argsort(arr[:,2])]




temp = [xsort,ysort,zsort]
out = 0
for temptemp in temp:
    value = [[[0, 0, 0, 0] for y in range(M + 1)] for x in range(N + 1)]
    arr = temptemp
    for i in range(N):
        for j in range(M):
            temp = [value[i][j][0]+arr[i][0],value[i][j][1]+arr[i][1],value[i][j][2]+arr[i][2]]
            temp2 = sum(map(abs,temp))
            if temp2 > value[i][j+1][3]:
                value[i+1][j+1][0] = value[i][j][0] + arr[i][0]
                value[i + 1][j + 1][1]=value[i][j][1] + arr[i][1]
                value[i + 1][j + 1][2]=value[i][j][2] + arr[i][2]
                value[i + 1][j + 1][3] = temp2
            else:
                value[i + 1][j + 1][0] = value[i][j+1][0]
                value[i + 1][j + 1][1] = value[i][j+1][1]
                value[i + 1][j + 1][2] = value[i][j+1][2]
                value[i + 1][j + 1][3] = value[i][j+1][3]
    if value[N][M][3] > out:
        out = value[N][M][3]



print(out)



### FIXED CODE ###

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

arr = []

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

def tobin(x, n):
    return format(x, 'b').zfill(n)

ans = 0
for i in range(8):
    temp = tobin(i,3)
    buf = [0 for i in range(n)]
    for i in range(3):
        for j in range(n):
            if temp[i] == "0":
                buf[j] += -arr[j][i]
            else:
                buf[j] += arr[j][i]
    buf.sort(key=lambda x:-x)
    temp = 0
    for i in range(m):
        temp += buf[i]
    if temp > ans:
        ans = temp
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
count = 0

for i in range(10**10):
  for j in a:
    if j%2 != 0:
      print(count)
      exit()
  count += 1
  


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
count = 0

for i in range(10**10):
  for j in range(n):
    if a[j]%2 != 0:
      print(count)
      exit()
    else:
      a[j] = a[j]//2
  count += 1
### BUGGY CODE ###


from collections import defaultdict

def main():
    num, person_num = map(int, input().split())
    data = list(map(int, input().split()))

    dp = [defaultdict(int) for i in range(num)]
    dp[0][data[0] % person_num] += 1

    ans = 0
    for i in range(1, num):
        now_data = data[i]
        ans += dp[i - 1][0]
        for key in dp[i - 1].keys():
            now_ind = (key + now_data) % person_num
            dp[i][now_ind] += dp[i - 1][key]
        dp[i][now_data % person_num] += 1

    ans += dp[num - 1][0]

    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###


from collections import defaultdict


def main():
    num_box, num_people = map(int, input().split())
    data = list(map(int, input().split()))

    dp = defaultdict(int)
    dp[0] += 1
    count = 0
    for i in range(num_box):
        count += data[i]
        count %= num_people
        dp[count] += 1

    ans = 0
    for ele in dp.values():
        if ele >= 2:
            ans += (ele - 1) * ele // 2

    print(ans)





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

# N, M, K = map(int, input().split())
# N = int(input())
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
flag = False
ans_flag = True
# iは欲しい難易度
for i in T:
    # jは用意された問題の難易度
    for n, j in enumerate(D):
        if i == j:
            D.pop(n)
            # print(D)
            flag = True
            break
    if flag == False:
        print("NO")
        ans_flag = False
        break
    else:
        flag = False
if ans_flag == True:
    print("YES")


### FIXED CODE ###

import collections

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
flag = False
ans_flag = True
d = collections.Counter(D)
t = collections.Counter(T)
# print(d.most_common())
# print(t.most_common())
for i in t:
    i_str = str(i)
    d_count = d[i]
    if d_count < t[i]:
        print("NO")
        ans_flag = False
        break

if ans_flag == True:
    print("YES")
### BUGGY CODE ###

import itertools
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,MOD = map(int,input().split())
if N == 1:
    print(1)
    exit()
graph = [set() for _ in range(N+1)]
for _ in range(N-1):
    x,y = map(int,input().split())
    graph[x].add(y)
    graph[y].add(x)

def dfs_1(v=1,parent=None):
    # 子ごとに、そこを黒くして適切 or 完全白
    # dp_1 + 1 の積
    x = 1
    graph[v].discard(parent)
    for w in graph[v]:
        x *= (dfs_1(w,v) + 1)
    dp_1[v] = x
    return x

dp_1 = [0] * (N+1) # 自分を黒く塗って、子側の部分木を適切に塗る方法
dfs_1()

def dfs_2(v=1,parent=None,x=1):
    # それぞれの子以外の情報をマージして、子に渡さなければいけない
    arr = [1 + dp_1[w] for w in graph[v]] + [x]
    L = [1] + list(itertools.accumulate(arr[:-1], lambda x,y: x*y%MOD))
    R = list(itertools.accumulate(arr[::-1][:-1], lambda x,y: x*y%MOD))[::-1] + [1]
    products = [x*y%MOD for x,y in zip(L,R)]
    dp[v] = arr[0] * products[0] % MOD
    for w,p in zip(graph[v],products):
        if w==parent:
            continue
        dfs_2(w,v,p+1)

dp = [0] * (N+1)
dfs_2()

print('\n'.join(map(str,dp[1:])))



### FIXED CODE ###

import itertools
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,MOD = map(int,input().split())
if N == 1:
    print(1)
    exit()
graph = [set() for _ in range(N)]
for row in sys.stdin.readlines():
    x,y = map(int,row.split())
    graph[x-1].add(y-1)
    graph[y-1].add(x-1)

ldp = [None] * N
rdp = [None] * N

def dfs_1(v=0,parent=None):
    # 子ごとに、そこを黒くして適切 or 完全白
    graph[v].discard(parent)
    ldp[v] = [1] * (len(graph[v])+1)
    rdp[v] = [1] * (len(graph[v])+1)
    vals = [dfs_1(w,v)+1 for w in graph[v]]
    for i,x in enumerate(vals,1):
        ldp[v][i] = ldp[v][i-1] * x % MOD
    for i,x in enumerate(reversed(vals),1):
        rdp[v][-i-1] = rdp[v][-i] * x % MOD
    return ldp[v][-1]

dfs_1()

dp = [None] * N
q = [(0,1)]
while q:
    v,x = q.pop()
    dp[v] = x*ldp[v][-1]%MOD
    for w,L,R in zip(graph[v],ldp[v][:-1],rdp[v][1:]):
        q.append((w,x*L*R%MOD+1))

print('\n'.join(map(str,dp)))
### BUGGY CODE ###

# encoding: utf-8
import sys
from collections import deque
input = sys.stdin.readline

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

q = deque([(b, [])])
while len(q) > 0:
    b, seq = q.pop()
    if len(b) == 0: break
    for i, bi in enumerate(b):
        if i + 1 == bi:
            if i == 0: q.append((b[i + 1:], seq + [i + 1]))
            elif i == len(b) - 1: q.append((b[:i], seq + [i + 1]))
            else: q.append((b[:i] + b[i + 1:], seq + [i + 1]))
else:
    seq = [-1]

for i in seq[::-1]: print(i)

### FIXED CODE ###

# encoding: utf-8
import sys
from collections import deque
input = sys.stdin.readline

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

for i, bi in enumerate(b):
    if i + 1 < bi:
        q = deque([])
        break
else:
    q = deque([(b, [])])
    
while len(q) > 0:
    b_tmp, seq = q.pop()
    if len(b_tmp) == 0: break
    for i, bi in enumerate(b_tmp):
        if i + 1 < bi: break
        elif i + 1 == bi:
            if i == 0: q.append((b_tmp[i + 1:], seq + [i + 1]))
            elif i == len(b_tmp) - 1: q.append((b_tmp[:i], seq + [i + 1]))
            else: q.append((b_tmp[:i] + b_tmp[i + 1:], seq + [i + 1]))
else:
    seq = [-1]

for i in seq[::-1]: print(i)
### BUGGY CODE ###

n1 = int(input())
A = list(map(int, input().split()))
n2 = int(input())
q = list(map(int, input().split()))

B = []

n = n1

for r in q:
    ans = "no"
    for i in range(2 ** n):
        B = list(map(int, format(i, "b").zfill(n)))[::-1]
        C = [ x*y for x, y in zip(A, B)]
        if sum(C) == r:
            ans = "yes"
            break
    print(ans)

### FIXED CODE ###

n1 = int(input())
A = list(map(int, input().split()))
n2 = int(input())
q = list(map(int, input().split()))

B = []
C = []
n = n1
ans = list("no" for i in range(n2))

for i in range(2 ** n):
    C0 = []
    B = list(map(int, format(i, "b").zfill(n)))[::-1]
    C0 = [ x*y for x, y in zip(A, B)]
    C.append(sum(C0))

for j, r in enumerate(q):    
    if  r in C:
        ans[j] = "yes"

print(*ans, sep="\n")
### BUGGY CODE ###

n = int(input())


def digits_of(n):
    digits = [] 
    while n != 0:
        r = n % 10 
        digits.append(r) 
        n = n // 10  
    return digits


def is_multiple_of_9(n): 
    sum = 0  
    for i in digits_of(n):
        sum += i
    return sum % 9 == 0


if is_multiple_of_9(n):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

n = int(input())


def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)


resu = digitSum(n) % 9
if resu == 0:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

import math
x=int(input())
for i in range(1,int(math.sqrt(x)+1)):
    if x % i==0:
        t=i
        w=x//i
        a=0
        while a<=t:
            b=a-t
            if a**5-b**5==x:
                print(a,b)
                exit()
            a+=1
        a = 0
        while a <= w:
            b = a - w
            if a ** 5 - b ** 5 == x:
                print(a, b)
                exit()
            a += 1








### FIXED CODE ###

import math
x=int(input())
for i in range(1,150):
    a=i**5
    for j in range(-150,150):
        if a-j**5==x:
            print(i,j)
            exit()
### BUGGY CODE ###

h, w, d = map(int, input().split())
a = []
dict = {}
for i in range(h):
	b = list(map(int, input().split()))
	for j in range(w):
		dict[b[j]] = [i,j]

q = int(input())
for i in range(q):
	l, r = map(int, input().split())
	cnt = 0
	v =[]
	for j in range(l,r+1,d):
		v.append(dict[j])
	for j in range(len(v)-1):
		cnt += abs(v[j+1][1]-v[j][1]) + abs(v[j+1][0]-v[j][0])
	print (cnt)


### FIXED CODE ###

h, w, d = map(int, input().split())
a = []
dict = {}
for i in range(h):
	b = list(map(int, input().split()))
	for j in range(w):
		dict[b[j]] = [i,j]

dist = [0 for i in range(h*w)]
for i in range(1,h*w-d+1):
	dist[i-1] = abs(dict[i+d][1]-dict[i][1]) + abs(dict[i+d][0]-dict[i][0])

for i in range(h*w-d-1,-1,-1):
	dist[i] += dist[i+d]

q = int(input())
for i in range(q):
	l, r = map(int, input().split())
	ans = dist[l-1] - dist[r-1]
	print (ans)
### BUGGY CODE ###

s = input()
l = len(s)
res = []

def dfs(s, i, j):
    if j - i <= 3:
        return 0
    if int(s[i:j]) % 2019 == 0 and (i, j) not in res:
        res.append((i, j))
        return 1
    return dfs(s, i + 1, j) + dfs(s, i, j - 1)

print(dfs(s, 0, len(s)))

### FIXED CODE ###

s = input()
l = len(s)
dp = [0 for i in range(2019)]
dp[0] = 1
r = 0
for i in range(1, l + 1):
    r += int(s[-i]) * pow(10, i - 1, 2019)
    r %= 2019
    dp[r] += 1
    
print(sum([(i * (i - 1)) // 2 for i in dp]))
### BUGGY CODE ###

#!/usr/bin/env python3
from collections import deque
from sys import setrecursionlimit

setrecursionlimit(10 ** 8)


def dfs(now):
    seen[now] = True
    for next in branch[now]:
        if seen[next] is False:
            tree[now].append(next)
            dfs(next)
    return tree


N, Q = map(int, input().split())
branch = [set() for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    branch[a - 1].add(b - 1)
    branch[b - 1].add(a - 1)
operation = [list(map(int, input().split())) for _ in range(Q)]

seen = [False] * N
tree = [[] for _ in range(N)]
for i in range(N):
    if seen[i] is False:
        dfs(i)
score = [0 for _ in range(N)]
for q in operation:
    root, pnt = q
    root -= 1
    tmp_lst = deque([root])
    while tmp_lst:
        now = tmp_lst.pop()
        score[now] += pnt
        for next in tree[now]:
            tmp_lst.append(next)

for ans in score:
    print(ans, end=' ')


### FIXED CODE ###

#!/usr/bin/env python3
from sys import setrecursionlimit

setrecursionlimit(10 ** 8)


def dfs(now):
    seen[now] = True
    score[now] += operation[now]
    for next in branch[now]:
        if seen[next] is False:
            score[next] += score[now]
            dfs(next)


N, Q = map(int, input().split())
branch = [set() for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    branch[a - 1].add(b - 1)
    branch[b - 1].add(a - 1)
operation = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    operation[p - 1] += x

seen = [False] * N
score = [0] * N
for i in range(N):
    if seen[i] is False:
        dfs(i)

for ans in score:
    print(ans, end=' ')
### BUGGY CODE ###

cou = int(input())
bars = input().split()
two = [0, 0]
i = 0
ca = len(bars)
while i < ca:
    if bars[i] in two:
        pass
    else:
        now = bars[i]
        if bars.count(now) > 3:
            two.extend(now)
            two.extend(now)
        elif bars.count(now) > 1:
            two.extend(now)
        else:
            pass
    i += 1
two.sort(key=int)
ans = int(two[-1]) * int(two[-2])
print(ans)


### FIXED CODE ###

n=input()
a = list(map(int, input().split()))
a.sort()
h, w =0, 0
while True:
    try:
        if a[-1] == a[-2]:
            h = a[-1]
            a.pop()
            a.pop()
            break
        else:
            a.pop()
    except:
        break

while True:
    try:
        if a[-1] == a[-2]:
            w = a[-1]
            a.pop()
            a.pop()
            break
        else:
            a.pop()
    except:
        break
print(h*w)
### BUGGY CODE ###

n=int(input())
p=list(map(int,input().split()))
ct=1
maxn=p.index(1)
for i in range(1,len(p)):
    if p.index(i+1)<maxn:
        maxn=p.index(i+1)
        ct+=1
print(ct)

### FIXED CODE ###

n=int(input())
p=list(map(int,input().split()))
ct=1
minn=p[0]
for i in range(1,n):
    if minn==1:
        #ct+=1
        break
    elif minn>p[i]:
        minn=p[i]
        ct+=1
print(ct)
### BUGGY CODE ###

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
inf = float('inf')
ans = int(0)

N = I()
color = []
a = I()
maxcolor =[]
maxcolor.append(a)
lena = 1
for i in range(N-1):
    a = I()
    minmaxcolor = min(maxcolor)
    if a<=minmaxcolor:
        maxcolor.append(a)
        lena += 1
    else:
        aupper = lena-1
        alower = int(0)
        acandi = aupper//2
        while (True):
            if maxcolor[acandi]>=a:
                alower = acandi
                acandi = (aupper+acandi+1)//2
            else:
                if aupper - alower <= 1:
                    maxcolor[acandi] = a
                    break
                else:
                    aupper = acandi
                    acandi = (acandi + alower) // 2


#print(maxcolor)
ans = len(maxcolor)
print(ans)

### FIXED CODE ###

from collections import deque
import bisect
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
ans = int(0)

N = I()
color = []
a = I()
maxcolor =deque()
maxcolor.append(a)
lena = 1
for i in range(N-1):
    minmaxcolor = maxcolor[0]
    a = I()
    if a<=minmaxcolor:
        maxcolor.appendleft(a)
#        maxcolor.append(a)
        lena += 1
    else:
        acandi = bisect.bisect_left(maxcolor, a)
        maxcolor[acandi-1] = a
        """
        aupper = lena-1
        alower = int(0)
        acandi = aupper//2
        
        for _ in range(aupper+1):
            if maxcolor[acandi]>=a:
                alower = acandi
                acandi = (aupper+acandi+1)//2
            else:
                if aupper - alower <= 1:
                    maxcolor[acandi] = a
                    break
                else:
                    aupper = acandi
                    acandi = (acandi + alower) // 2
        """

#print(maxcolor)
ans = len(maxcolor)
print(ans)
### BUGGY CODE ###

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

l = []
for i in range(x):
    for j in range(y):
            l.append(a[i] + b[j])

l = sorted(l,reverse=True)
ll = []
for i in range(min(len(l),k)):
    for j in range(z):
        ll.append(l[i] + c[j])

ll = sorted(ll,reverse=True)
for i in range(k):
    print(ll[i])


### FIXED CODE ###

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

l = []
for i in range(x):
    for j in range(y):
            l.append(a[i] + b[j])

l = sorted(l,reverse=True)
ll = []
for i in range(min(len(l),k)):
    for j in range(z):
        ll.append(l[i] + c[j])

ll = sorted(ll,reverse=True)
for i in range(k):
    print(ll[i])
### BUGGY CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
T = set([_I() for _ in range(N)])

times = 1
max_v = max(T)
while True:
    max_t = max_v * times
    for t in T:
        if max_t % t != 0:
            times += 1
            break
    else:
        print(max_t)
        break




### FIXED CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
T = set([_I() for _ in range(N)])

def lcm(a,b):
    g = fractions.gcd(a,b)
    return a * b // g

l = 1
for t in T:
    l = lcm(l, t)

print(l)
### BUGGY CODE ###

import numpy as np
MOD = 10 ** 9 + 7

dp = np.zeros(13, dtype = np.int64)
dp[0] = 1

for s in input():
  prev = dp
  dp = np.zeros(13, dtype=np.int64)
  if s == '?':
    add = range(10)
  else:
    add = [int(s)]
  for x in add:
    dp[(np.arange(x,130,10)) % 13] += prev
  dp %= MOD
  
print(dp[5])


### FIXED CODE ###

MOD = 10 ** 9 + 7
S = input()

dp = [0] * 13
dp[0] = 1

for s in S:
  prev = [x for x in dp]
  dp = [0] * 13
  if s == '?':
    add = range(10)
  else:
    add = [int(s)]
  for i in range(13):
    for x in add:
      dp[(10*i+x)%13] += prev[i]
  dp = [x % MOD for x in dp]
  
print(dp[5])
### BUGGY CODE ###

def solve(string):
    n, *a = map(int, string.split())
    a = [list(map(int, "{:060b}".format(_a))) for _a in a]
    m = 10**9 + 7
    ans = 0
    for i, d in enumerate(zip(*a)):
        ans += sum(d) * (n - sum(d)) * pow(2, 59 - i, m) % m
        ans %= m
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


### FIXED CODE ###

def solve(string):
    n, *a = map(int, string.split())
    a = ["{:060b}".format(_a) for _a in a]
    m = 10**9 + 7
    ans = 0
    for i, d in enumerate(zip(*a)):
        s = "".join(d).count("1")
        ans += s * (n - s) * pow(2, 59 - i, m)
        ans %= m
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))