Problem:
Least Common Multiple Find the least common multiple (LCM) of given n integers. Input  n  a 1  a 2 ... a n   n is given in the first line. Then, n integers are given in the second line. Output Print the least common multiple of the given integers in a line. Constraints  2 ≤ n ≤ 10  1 ≤ a i ≤ 1000  Product of given integers a i ( i = 1, 2, ... n ) does not exceed 2 31 -1  Sample Input 1 3
3 4 6 Sample Output 1 12 Sample Input 2 4
1 2 3 5 Sample Output 2 30

Solution (Python):
import math
from functools import reduce

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


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


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


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


print(lcm(*(a)))

Solution (Python):
import math
n=int(input())
L=list(map(int,input().split()))
print
if n==1:
    print(L[0])
else:
    x=L[0]
    for i in range(1,n):
        x=(x*L[i])//math.gcd(x,L[i])
        i+=1
    print(x)

Solution (Python):



import fractions

n = int(input())

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

ans = a[0]

for i in range(1,n):
    ans = ans*a[i] // fractions.gcd(ans,a[i])
print(ans)

Solution (Python):
import fractions
n=int(input())
a=list(map(int,input().split()))
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
print(ans)

Solution (Python):
import math
from functools import reduce
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
n=int(input())
a=map(int,(input().split()))
print(reduce(lcm,a))

Solution (Python):
import fractions

n=int(input())
m=list(map(int,input().split()))
ans = m[0]
for i in range(1,n):
    ans =ans*m[i]//fractions.gcd(ans,m[i])
print(ans)

Solution (Python):
import fractions
n=int(input())
a=list(map(int,input().split()))
ans=a[0]
for i in range(1,n):
    ans=ans*a[i] // fractions.gcd(ans,a[i])
print(ans)

Solution (Python):
import math
from functools import reduce

def lcm_base(x,y):
    return (x*y)//math.gcd(x,y)
def lcm(*numbers):
    return reduce(lcm_base,numbers,1)
 
x=int(input()) 
a=[int(i) for i in input().split()]

print(lcm(*a))

Solution (Python):
import fractions
N = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans =ans * a[i] // fractions.gcd(ans, a[i])
print(ans)

Solution (Python):

import fractions
n = int(input())
a = list(map(int,input().split()))
ans = a[0]
for i in range(1,n):
    ans = ans * a[i] // fractions.gcd(ans,a[i])

print(ans)

Solution (Python):

import math
i = int(input())
line = list(map(int,input().split()))


n = line[0]


for l in range(1,i):n = int(n * line[l] / math.gcd(n,line[l]))


print(n)

Solution (Python):
import fractions
n=int(input())
a=list(map(int, input().split()))
b=a[0]
for i in range(1, n):
    b=b*a[i]//fractions.gcd(b, a[i])
print(b)

Solution (Python):
from math import gcd
n = int(input())
a = list(map(int, input().split()))

x = a[0]
for i in range(1,n):
    x = (x*a[i]//gcd(x,a[i]))
    
print(x)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

def my_lcm(a, b):
    cum = a * b
    if a > b:
        a, b = b, a
    while a != 0:
        a, b = b % a, a
    
    return cum // b


res = 1
for i in a:
    res = my_lcm(res, i)
print(res)

Solution (Python):
def gcd(a,b):
    if a<b:
        a,b=b,a
    if b==0:
        return a
    return gcd(b,a%b)

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

n=int(input())
a=list(map(int,input().split()))
b=1
for i in a:
    b=lcm(b,i)
print(b)

Solution (Python):
import math
def lcm(x,y):
    return (x*y)//math.gcd(x,y)

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

x=lcm(a[0],a[1])
i=2
for i in range(n):
    x=lcm(x,a[i])
    
print(x)

Solution (Python):
from functools import reduce

def factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def is_prime(n):
    if n < 2:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def gcd_base(x, y):
    if x % y:
        return gcd_base(y, x%y)
    return y

def gcd(numbers):
    return reduce(gcd_base, numbers)

def lcm_base(x, y):
    res = (x * y) // gcd_base(x, y)
    return res 

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

n = int(input())
a = [int(i) for i in input().split()]
print(lcm(a))

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
import math
lcm = a[0]
for i in a[1:]:
    lcm = i * lcm // math.gcd(lcm, i)
print(lcm)

Solution (Python):
import fractions
n = int(input())

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

a = list(map(int,input().split()))
ans = 1
for i in a:
	ans = lcm(ans, i)
print(ans)

Solution (Python):
import math
n=int(input())
lst=list(map(int,input().split()))

ans=lst[0]
for i in range(1,n):
    ans=ans*lst[i]//math.gcd(ans,lst[i])
print(ans)

Solution (Python):
def factrize(x):
    
    f = {}
    tmp = x
    i = 2
    while i**2 <= tmp:
        cnt = 0
        while tmp % i == 0:
            cnt += 1
            tmp = tmp // i
        if cnt > 0:
            f[i] = cnt
        i += 1
    if tmp != 1 or f == {}:
        f[tmp] = 1
    return f


n = map(int, input().split())
*A, = map(int, input().split())
A = [factrize(a) for a in A]
F = {}
for f in A:
    for p in f:
        try:
            F[p] = max(F[p], f[p])
        except KeyError:
            F[p] = f[p]
ans = 1
for p in F:
    ans *= p**F[p]
print(ans)

Solution (Python):
import math
from functools import reduce

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())

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

print(lcm(*a))

Solution (Python):
def gcd(a,b):
    if a<b:
        a,b=b,a
    if b==0:
        return a
    return gcd(b,a%b)

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

n=int(input())
a=list(map(int,input().split()))
b=1
for i in a:
    b=lcm(b,i)
print(b)

Solution (Python):



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

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

l = A[0]
for i in range(1, n):
   l = l * A[i] / gcd(l, A[i])
print(int(l))

Solution (Python):
from math import gcd
a=1
n=int(input())
l=list(map(int,input().split()))
for i in l:
    a=a*i//gcd(a,i)
print(a)

Solution (Python):
from itertools import accumulate


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


def LCM(a, b):
    return a // GCD(a, b) * b


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    lcm = 1
    ans = list(accumulate(A, func=LCM))[-1]
    print(ans)

Solution (Python):
from functools import reduce

def gcd(m, n):
    if m < n:
        return gcd(n, m)
    if n == 0:
        return m
    return gcd(n, m % n)

def lcm(m, n):
    return m * n // gcd(m, n)

n = int(input())
l = [int(arg) for arg in input().split()]
print(reduce(lcm, l, l[0]))

Solution (Python):
from functools import reduce
import math

n = int(input())

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

numlis = [int(a) for a in input().split()]
print(lcm_list(numlis))

Solution (Python):
import math
from functools import reduce
n=int(input())
z=list(map(int,input().split()))
def lcm_b(x,y):
    return (x*y)//(math.gcd(x,y))
def lcm(*z):
    return reduce(lcm_b,z,1)
print(lcm(*z))

Solution (Python):
import math
from functools import reduce
n = int(input())
A = tuple(map(int, input().split()))
print(reduce(lambda a, b: a*b // math.gcd(a, b), A))

Solution (Python):
import math
from functools import reduce

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
print(lcm(*map(int, input().split())))

Solution (Python):
def gcd(a, b) :
    while True :
        if a < b :
            a, b = b, a
        amari = a % b
        if amari == 0 :
            break
        else :
            a, b = b, amari
    return(b)

n = int(input())
c = list(map(int, input().split()))
for i in range(n-1, 0, -1) :
    c[i-1] = int(c[i] * c[i-1] / gcd(c[i], c[i-1]))
print(c[0])

Solution (Python):
import fractions
n = int(input())
a = list(map(int, input().split()))
x = a[0]
for i in range(1, n):
    x = x * a[i] // fractions.gcd(x, a[i])
print(x)

Solution (Python):
from math import gcd
a = int(input())  
b = list(map(int, input().split()))  
lcm = b[0]  
for m in b[1:]:
    lcm = int((lcm*m)/gcd(lcm, m))  
print(lcm)

Solution (Python):
import fractions
n=int(input())
x=list(map(int,input().split()))
ans=x[0]
for i in range(1,n):
    ans=ans*x[i]//fractions.gcd(ans,x[i])
print(ans)

Solution (Python):
import math

n = int(input())
A = [int(a) for a in input().split()]

ans = A[0]

for i in range(1, n) :
    ans = ans * A[i] // math.gcd(ans, A[i])
    
print(ans)

Solution (Python):
N=input()
target = list(map(int, input().split()))

def calc_factors(N):
    n = int(N**.5)
    arr = []
    tmp = N
    for i in range(2,n+1):
        if tmp % i == 0:
            while tmp % i == 0:
                arr.append(i)
                tmp = int(tmp/i)
    if tmp != 1: arr.append(tmp) 
    return arr

d = {}
for i in target:
    arr = calc_factors(i)
    for a in set(arr):
        if a in d.keys():
            d[a] = max(d[a], arr.count(a))
        else:
            d[a] = arr.count(a)
res = 1
for k,v in d.items():
    res*=(int(k)**int(v))
print(res)

Solution (Python):








import sys,bisect,math
from functools import reduce
sys.setrecursionlimit(15000)

N = int(sys.stdin.readline())
A = list(map(int,sys.stdin.readline().split()))

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

print(reduce(lcm,A))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

from math import gcd

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


tmp = lcm(a[0], a[1])
for i in range(2, n):
	tmp = lcm(tmp, a[i])

print(tmp)

Solution (Python):
import math

n=int(input())
a=list(map(int,input().split()))
def lcm(a,b):
    return a*b/math.gcd(a,b)
ans=int(lcm(a[0],a[1]))
for i in range(2,len(a)):
    ans=int(lcm(ans,a[i]))
print(int(ans))

Solution (Python):
def gcd(a,b):
    while b != 0:
        a,b = b,a%b
    return a

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

N = int(input())
a = list(map(int,input().split()))
f = a[0]

for i in range(1,N):
    f = lcm(f,a[i])

print(f)

Solution (Python):
n=int(input())
*a,=map(int, input().split())

def gcd(a,b):
    while b: a,b=b,a%b
    return a

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

ans = 1
for ai in a:
    ans = lcm(ans, ai)
print(ans)

Solution (Python):
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

def lcm_list(numbers):
    return reduce(lcm, numbers)

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

print(lcm_list(a))

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

def elements(dim):
    ans = []
    cnt = 2
    while cnt <= dim:
        if dim % cnt == 0:
            dim //= cnt
            ans.append(int(cnt))
            cnt = 2
        else:
            cnt += 1
    return ans

l_e = []

for i in l:
    i_e = elements(i)
    for j in i_e:
        if j in l_e:
            l_e.remove(j)
    l_e += i_e

out = 1
for i in l_e:
    out *= i
print(out)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))

def gcd(x,y):
    if x<y:x,y = y,x
    if y==0:return x
    return gcd(y,x%y)
ans = a[0]
for i in range(n-1):
    b = gcd(ans,a[i+1])
    ans *= a[i+1]//b
print(ans)

Solution (Python):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

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

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

ans = 1
for b in A:
    ans = lce(ans, b)

print(ans)

Solution (Python):
import fractions

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

def lcm(Numbers):
    N = len(Numbers)
    if N == 1:
        return Numbers[0]
    else:
        Numbers[N-2] = \
        Numbers[N-1]*Numbers[N-2] \
        //fractions.gcd(Numbers[N-1],Numbers[N-2])
        return lcm(Numbers[0:N-1])

print(lcm(Numbers))

Solution (Python):
from math import gcd
n = int(input())
a = list(map(int, input().split()))
g = a[0]
lcm = 0
for i in range(1, n):
    tmp = gcd(g, a[i])
    lcm = g * a[i] // tmp
    g = lcm
    tmp = lcm
print(lcm)

Solution (Python):

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

n = int(input())
a = list(map(int,input().split()))
print(lcm(a))

Solution (Python):

def getLCM(num1,num2):
    base1 = num1
    base2 = num2
    while 1:
        if num1 < num2:
            num1 =  num1 + base1
        elif num1 > num2:
            num2 =  num2 + base2
        elif num1 == num2:
            return num1

def getNextLCM(base1,base2,lcm):
    num1 = lcm + base1
    num2 = lcm
    while 1:
        if num1 < num2:
            num1 =  num1 + base1
        elif num1 > num2:
            num2 =  num2 + base2
        elif num1 == num2:
            return num1
while 1:
    try:
        n = int(input())
        numbers = list(int(x) for x in input().split())
    except:break
    
    
    if 1 in numbers:
        numbers.remove(1)
    numbers = sorted(numbers)
    reduceIndex = []
    size = len(numbers) - 1
    
    
    
    
    
    
    while(size > 1):
        isReduce = False
        
        for i in range(size - 1,-1,-1) :
            if numbers[size] % numbers[i] == 0:
                reduceIndex.append(numbers[i])
                isReduce = True
        for i in reduceIndex:
            numbers.remove(i)
        if isReduce:
            size = len(numbers) - 1
            reduceIndex.clear()
        else:
            size = size - 1
            
    
    
    
    
    size = len(numbers)
    if size == 1:
        print(numbers[size - 1])
        break
    
    lcm = getLCM(numbers[size - 1],numbers[size - 2])
    
    while(1):
        isFind = True
        for i in range(size - 2,-1,-1):
            
            
            if lcm % numbers[i] != 0:
                i = -1
                isFind = False
 
        if isFind:
            break
        else:
            lcm = getNextLCM(numbers[size - 2],numbers[size - 1],lcm)
    print(lcm)

Solution (Python):
from functools import reduce

def gcd(x,y):
    while y:
        x,y = y,x%y
    return x

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

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

print(reduce(lcm,A))

Solution (Python):
import math
n = int(input())
r = 1
for i in map(int, input().split()):
	r = r // math.gcd(r,i) * i	
print(r)

Solution (Python):
n=int(input())

def GCD(a,b):
    if min(a,b)==0:
        return max(a,b)
    else:
        return GCD(min(a,b),max(a,b)%min(a,b))

def LCM(a,b):
    return (a*b)//GCD(a,b)

a=[int(i) for i in input().split(" ")]

lcm=1
for ai in a:
    lcm=LCM(ai,lcm)
print(lcm)

Solution (Python):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

def lcm(a, b):
    return a * b // gcd(a, b)
 
from functools import reduce

n = int(input())
a = list(map(int, input().split()))
print(reduce(lcm, a))

Solution (Python):
import math

n=int(input())
A=list(map(int,input().split()))
x=1
for a in A:
    x=a*x//math.gcd(a,x)

print(x)

Solution (Python):
from math import gcd


def lcm(arr):
    ret = 1
    for a in arr:
        ret = ret * a // gcd(ret, a)
    return ret


def aoj():
    N = int(input())
    print(lcm([int(x) for x in input().split()]))


if __name__ == '__main__':
    aoj()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
import math
def lcm(a,b):
	return a*b//(math.gcd(a,b))
ans=1
for i in range(n):
	ans=lcm(ans,a[i])
print(ans)

Solution (Python):
n = int(input())
L = list(map(int,input().split()))
def gcd(a,b):
    while b != 0:
        k = b
        b = a%b
        a = k
    return a
g = gcd(max(L[0],L[1]),min(L[0],L[1]))
lcm = L[0]*L[1]//g
for i in range(2,len(L)):
    cur = gcd(max(lcm,L[i]),min(lcm,L[i]))
    if lcm%L[i] == 0:
        None
    elif L[i]%lcm == 0:
        lcm = L[i]
    else:
        lcm = lcm*L[i]//cur
print(lcm)

Solution (Python):
def gcm(a,b):
    if a < b:
        a,b = b,a
    while True:
        if a % b == 0:
            return b
        else:
            a,b = b,a % b

def lcm(a,b):
    g = gcm(a,b)
    return a*b//g;

n = int(input())
Data = list(map(int,input().split()))
ans = lcm(Data[0],Data[1])
for i in range(2,len(Data)):
    ans = lcm(ans,Data[i])
print(ans)

Solution (Python):

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

lcm = 1
for a in A:
    lcm = (lcm*a)//math.gcd(lcm,a)

print(lcm)

Solution (Python):
import math
input()
L = list(map(int, input().split()))
m = [ [] for x in range(len(L))]
for i in range(len(L)):
    n = L[i]
    k = n
    for j in range(2, int(math.sqrt(n))+1):
        if j > k:
            break
        while k % j ==0:
            m[i].append(j)
            k = k // j
            if k == 1:
                break
    if k != 1:
        m[i].append(k)
s = set()
for i in m:
    s |= set(i)
lcm = 1
for i in s:
    lcm *= i**max([ m[x].count(i) for x in range(len(L))] )
print(lcm)

Solution (Python):
from math import*;n,a=open(0);l=1
for x in map(int,a.split()):l=l*x//gcd(x,l)
print(l)

Solution (Python):
def gcd(a, b):
    """a, bの最大公約数(greatest common divisor:GCD)を求める"""
    if b == 0:
        return a
    return gcd(b, a%b)


def multi_lcm(array):
    """arrayのLCMを求める"""
    ans = array[0]
    for i in range(1, len(array)):
        ans = (ans * array[i]) // gcd(ans, array[i])
    return ans


n = int(input())
a = list(map(int, input().split()))
print(multi_lcm(a))

Solution (Python):





from sys import stdin,setrecursionlimit


setrecursionlimit(10**6)
input=stdin.readline

def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

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

n=int(input().rstrip())
a=[int(i) for i in input().split()]
ans=a[0]
for i in range(1,n):
    ans=lcm(ans,a[i])
print(ans)

Solution (Python):
import sys
import math

z=input()
n=list(map(int,input().split()))
k={}
L={}

for num in n:
  
  i=num
  j=2
  k.clear()
  while i>1:
    if i%j==0:
      if j in k:
        k[j]+=1
      else:
        k[j]=1
      i/=j
      j=2
    else:
      j+=1
      
  for i in k:
    if i in L:
      if k[i]>L[i]:
        L[i]=k[i]
    else:
      L[i]=k[i]


ans=1
for i in L:
  ans*=i**L[i]

print(ans)

Solution (Python):
import copy
import math
from typing import List


def compute_prime_factor(n: int) -> None:
    global prime_factors
    sqrt_n = int(math.sqrt(n)) + 1
    for i in range(2, sqrt_n + 1):
        if 0 == (n % i):
            prime_factors.append(i)
            compute_prime_factor(n // i)
            return
    if 1 != n:
        prime_factors.append(n)
        return


if __name__ == "__main__":
    n = int(input())
    A = list(map(lambda x: int(x), input().split()))

    prime_factor_dict: dict = {}
    for i in range(n):
        prime_factors = []  
        compute_prime_factor(A[i])
        prime_factor_dict[A[i]] = prime_factors

    max_num = max(A)
    all_factors: List[int] = prime_factor_dict[max_num]
    for key, factors in prime_factor_dict.items():
        if key == max_num or key == 1:
            continue
        tmp = copy.deepcopy(prime_factor_dict[max_num])
        for elem in factors:
            if elem in tmp:
                tmp.pop(tmp.index(elem))
            else:
                all_factors.append(elem)

    ans = 1
    for elem in all_factors:
        ans *= elem
    print(ans)

Solution (Python):
import math

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

n = int(input())
A = list(map(int, input().split()))
ans = 1

for a in A:
    ans = lcm(ans, a)
print(ans)

Solution (Python):
import math

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

lcm = a[0]
for i in range(1, n):
    lcm = (lcm * a[i]) // math.gcd(lcm, a[i])
    
print(lcm)

Solution (Python):


import sys
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd
from functools import reduce

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(li): return reduce(lcm, li, 1)

N = INT()
A = LIST()
print(lcm_list(A))

Solution (Python):
import math
input()
b = 1
for a in [int(x) for x in input().split()]:
    b = a * b // math.gcd(a, b)
print(b)

Solution (Python):

"""
Elementary Number Theory - Least Common Multiple
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_C&lang=jp

"""
import sys
from math import gcd
from functools import reduce

def solve(A):
    return reduce(lambda x, y: x * y // gcd(x, y), A)


def main(args):
    _ = input()
    A = [int(a) for a in input().split()]
    ans = solve(A)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
n=int(input())
L=input().split( )
a=[int(L[i]) for i in range(n)]
for i in range(n-1):
    x=a[i]
    y=a[i+1]
    while x%y!=0:
        w=y
        y=x%y
        x=w
    a[i+1]=a[i+1]*a[i]//y


print(a[n-1])

Solution (Python):
from fractions import gcd
n=int(input())
A=list(map(int,input().split()))
ans=A[0]
for i in range(n-1):
    i=A[i+1]
    g=gcd(ans,i)
    ans*=(i//g)
print(ans)

Solution (Python):
def euc(x, y):
	if y == 0: return x
	return euc(y, x%y)

N = int(input())
A = list(map(int, input().split()))
now = A[0]
for i in range(1, N):
	now = (now*A[i])//euc(now, A[i])
print(now)

Solution (Python):
def g(a, b):
    while b:
        a, b = b, a%b
    return a
n = int(input())
a = list(map(int, input().split()))
ans = a[0]*a[1]/g(a[0],a[1])
for i in a[2:]:
    ans = ans*i/g(ans,i)
print(int(ans))

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): 
	return list(map(int,input().split()))
def m(): 
	return map(int,input().split())
def onem(): 
	return int(input())
def s(x): 
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): 
	return " ".join(map(str,x))
def max2(x): 
	return max(map(max,x))

import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

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

n = onem()

l = l()

print(lcm_list(l))

Solution (Python):
def calc_gcd(x, y):
    
    if x < y:
        x, y = y, x

    while y > 0:
        x, y = y, x % y

    return x



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


a_last = None

for a in A:
    if a_last == None:
        a_last = a
        continue

    gcd = calc_gcd(a, a_last)
    
    a_last = a * a_last / gcd


print(int(a_last))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

import math

def LCM(i, j):
    return i * j // math.gcd(i, j)

ans = 1
for i in a:
    ans = LCM(ans, i)
print(ans)

Solution (Python):
import math

def main(n):
	ans = 1
	lst = list(map(int, input().split()))
	for i in lst:
		ans = ans * i // math.gcd(ans,i)
	print(ans)
main(int(input()))

Solution (Python):
import functools 

def gcd(a, b):
    if a > 0 and b == 0:
        return a
    if a < b:
        a, b = b, a
    r = a % b
    return gcd(b, r)

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

line = input()
n = int(line)
line = input()
a = list(map(int, line.split()))
print(functools.reduce(lambda x,y: lcm(x, y), a))

Solution (Python):
import math
def lcm(a,b):
    return a*b//math.gcd(a,b)
n=int(input())
a=list(map(int,input().split()))
result=a[0]
for i in range(1,n):
    result=lcm(result,a[i])
print(result)

Solution (Python):
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

n=int(input())
arr=list(map(int,input().split()))
for i in range(n-2,-1,-1):
  arr[i]=(arr[i]*arr[i+1])//gcd(arr[i],arr[i+1])
print(arr[0])

Solution (Python):
def g(a, b):
    while b:
        a, b = b, a%b
    return a
n = int(input())
a = list(map(int, input().split()))
ans = a[0]*a[1]/g(a[0],a[1])
for i in a[2:]:
    ans = ans*i/g(ans,i)
print(int(ans))

Solution (Python):
import math

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

for i in range(n - 1):
    num[i + 1] = int(num[i] * num[i + 1] / math.gcd(num[i], num[i + 1]))

print(int(num[n - 1]))

Solution (Python):
import math
n = int(input())
lst = list(map(int, input().split()))


def lcm(a, b):
    return a * b // math.gcd(a, b)
ans = 1
for _ in lst:
    ans = lcm(_, ans)

print(ans)

Solution (Python):
import math
n=int(input())
a=list(map(int,input().split()))
a_s=list(set(a))
while len(a_s)!=1:
    gcd=math.gcd(a_s[-1],a_s[-2])
    lcm=int(a_s[-1]*a_s[-2]/gcd)
    a_s=a_s[:-2]
    a_s.append(lcm)
print(a_s[0])

Solution (Python):
from math import gcd
from functools import reduce
def lcm(x, y):
  return x * y // gcd(x, y)
n = int(input())
alst = list(map(int, input().split()))
print(reduce(lcm, alst))

Solution (Python):
def lcm_base(x, y):
    return (x*y) // math.gcd(x, y)


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


import math
from functools import reduce

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

print(lcm_list(alist))

Solution (Python):
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
    
n = int(input())
a = list(map(int, input().split()))

lcm = 1
for i in a:
    lcm = lcm*i//gcd(lcm,i)

print(lcm)

Solution (Python):
import sys,math
from functools import reduce
input = sys.stdin.readline
n=int(input())
l=list(map(int,input().split()))

def lcm_base(x,y):
    return (x*y)//math.gcd(x,y)
def lcm(*N):
    return reduce(lcm_base,N,1)

print(lcm(*l))

Solution (Python):
import math
from typing import List
from functools import reduce

def least_common_multiple(x: int, y: int) -> int:
    return x * y // math.gcd(x, y)


def least_common_multiple_of_numbers(numbers: List[int]) -> int:
    if len(numbers) == 1:
        return numbers[0]

    
    
    
    
    
    
    
    

    return reduce(least_common_multiple, numbers)


def main():
    m = int(input())
    numbers = list(map(int, input().split()))
    gcm = least_common_multiple_of_numbers(numbers)
    print(gcm)
    return


main()

Solution (Python):
from functools import reduce

def gcd(a,b): 
    if ((a%b) == 0 ):
        return b
    else:    
        return (gcd(b,a%b))

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

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

print (reduce(lcm,l))

Solution (Python):
import sys


sys.setrecursionlimit(1000000)


def li_input():
    return [int(_) for _ in input().split()]

def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)

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

def lcm_list(L):
    _lcm = lcm(L[0], L[1])

    for i in range(2, len(L)):
        _lcm = lcm(_lcm, L[i])

    return _lcm

def main():
    N = int(input())
    L = li_input()

    print(lcm_list(L))


main()

Solution (Python):
import math

l = int(input())
a = list(map(int, input().split()))
dict = {}
for n in a:
    ans = []
    i = 2
    k = math.sqrt(n)
    dic = {}
    while i <= k:
        if n%i == 0:
            n = n//i
            ans.append(i)
            i -= 1
            if n == 1:
                break
        i += 1
    if len(ans) == 0 or n != 1:
        ans.append(n)
    for i in ans:
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1
    for i in dic.keys():
        if i in dict:
            dict[i] = max(dict[i], dic[i])
        else:
            dict[i] = dic[i]
sum = 1
for x,y in dict.items():
    sum *= x**y
print(sum)

Solution (Python):
n = int(input())
A = tuple(map(int, input().split()))
def gcd(a, b):
    if a < b:
        a, b = b, a
    while b != 0:
        a, b = b, a % b
    return a

b = A[0]
for a in A:
    b = a * b // gcd(a, b)
print(b)

Solution (Python):
def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	return gcd(b, a % b)

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

def lcml(l):
	if len(l) < 1:
		return 1
	elif len(l) == 1:
		return l[0]
	return lcm(l[0], lcml(l[1:]))

n = int(input())
print(lcml([int(x) for x in input().split()]))

Solution (Python):
n = int(input())
A = list(map(int, input().split()))

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

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

ans = A[0]
for i in range(n-1):
    ans = lcm(ans, A[i+1])

print(ans)

Solution (Python):
import functools
import math
n=int(input())
a=list(map(int,input().split(" ")))
print(functools.reduce(lambda x, y: x*y//math.gcd(x,y), a))