Problem:
Least Common Multiple

Find the least common multiple (LCM) of given n integers.

Input

n
a1 a2 ... an

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 ≤ ai ≤ 1000

Product of given integers ai(i = 1, 2, ... n) does not exceed 231-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 in Python3 (judge verdict: Wrong Answer)

def gcd(x,y):
    p=min(x,y)
    q=max(x,y)
    while True:
            m=q%p
            if m==0:
#                print(p,q,m,p)
                break
            p=m
            q=p
#    g=p
    if p==q:
        g=1
    else:
        g=p
    return g

c=0
n=int(input())
a=sorted(set(list(map(int, input().split()))))
b=[]
while len(a) > 1:
    n=len(a)
    for i in range(n-1):
        p=a[i]
        q=a[i+1]
        g=gcd(p,q)

        r=a[i]*a[i+1]//g
        b.append(r)
    a=sorted(b)
    b=[]
print(*a)