Problem:
Score : 300 points

Problem Statement

We have N clocks. The hand of the i-th clock (1≤i≤N) rotates through 360° in exactly T_i seconds.

Initially, the hand of every clock stands still, pointing directly upward.

Now, Dolphin starts all the clocks simultaneously.

In how many seconds will the hand of every clock point directly upward again?

Constraints

1≤N≤100

1≤T_i≤10^{18}

All input values are integers.

The correct answer is at most 10^{18} seconds.

Input

Input is given from Standard Input in the following format:

N
T_1
:
T_N

Output

Print the number of seconds after which the hand of every clock point directly upward again.

Sample Input 1

2
2
3

Sample Output 1

6

We have two clocks. The time when the hand of each clock points upward is as follows:

Clock 1: 2, 4, 6, ... seconds after the beginning

Clock 2: 3, 6, 9, ... seconds after the beginning

Therefore, it takes 6 seconds until the hands of both clocks point directly upward.

Sample Input 2

5
2
5
10
1000000000000000000
1000000000000000000

Sample Output 2

1000000000000000000

Solution in Rust (1.15.1) (judge verdict: Time Limit Exceeded)

use std::collections::HashMap;

fn collect_primes(n: u64) -> HashMap<u64, u32> {
    let mut primes = HashMap::<u64, u32>::new();
    let mut cur = n;
    let mut i = 2_u64;
    if n == 1 {
        primes.insert(1, 1);
        return primes;
    }
    while i != cur {
        if cur % i  == 0 {
            *(primes.entry(i).or_insert(0)) += 1;
            cur /= i;
            continue;
        }
        i += 1;
    }
    // primes.entry(cur).and_modify(|i| *i=*i+1).or_insert(1);
    if primes.get(&i).is_some() {
        let v = primes.get_mut(&i).unwrap();
        *v = *v + 1;
    } else {
        primes.insert(cur, 1);
    }

    primes
}

fn union_primes(l: HashMap<u64, u32>, r: HashMap<u64,u32>) -> HashMap<u64,u32>{
    let mut nprimes = l.clone();
    let t = 0;
    for p1 in l.keys() {
        let lp = l.get(p1).unwrap();
        let rp = r.get(p1).unwrap_or(&t);
        if lp > rp {
            nprimes.insert(*p1, *lp);
        } else {
            nprimes.insert(*p1, *rp);
        }
    }
    for p2 in r.keys() {
        let n = *(nprimes.get(p2).unwrap_or(&0));
        let rp = r.get(p2).unwrap();
        if n < *rp {
            nprimes.entry(*p2).or_insert(*rp);
        }
    }
    nprimes
}

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        n : usize,
        tx : [[u64; 1]; n],
    }
    let mut base = HashMap::<u64,u32>::new();
    for i in 0 .. n {
        let prime = collect_primes( tx[i][0] );
        base = union_primes(base, prime);
        // println!("{:?}", base);
    }
    let mut ans = 1u64;
    for (k,v) in base.iter() {
        // println!("{} {}", k,v);
        ans *= (*k as u64).pow(*v);
        // println!("ans {} ", ans);
    }
    println!("{}", ans)
}