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 C# (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    

    class Program
    {
      
        static void Main(string[] args)
        {

            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');

            int s = 1001;

            int[] data = new int[s];
            
            long ans = 1;
            int sisu_cnt = 0;
            
            for(int i = 0; i < n; i++)
            {
                int m = int.Parse(str[i]);

                
                //kは素因数
                for (int k = 2; k <= Math.Sqrt(m); k++)
                {
                    sisu_cnt = 0;
                    while (m % k == 0)
                    {
                        sisu_cnt++;                       
                        m = m / k;
                    }

                    if (data[k] < sisu_cnt) data[k] = sisu_cnt;                    
                    
                }
                if (m != 1 && data[m] == 0) data[m] = 1;
            }

            for(int i = 2; i < s; i++)
            {               
                if (data[i] != 0) ans *= (long)Math.Pow(i, data[i]);
            }

            Console.WriteLine(ans);

        }
    }
}