lcm(a,b,c) = lcm(lcm(a,b), c); lcm(a,b) = a*b/gcd(a,b)
rust []\nfn gcd(x: i64, y: i64) -> i64 {\n    if y == 0 {x} else {gcd(y, x % y)}\n}\n\nfn lcm(x: i64, y: i64) -> i64 {\n    x * y / gcd(x,y) \n}\n\n\nfn cum<I>(
```rust []\nfn gcd(x: i64, y: i64) -> i64 {\n    if y == 0 {x} else {gcd(y, x % y)}\n}\n\nfn lcm(x: i64, y: i64) -> i64 {\n    x * y / gcd(x,y) \n}\n\n\nfn cum<I>(xs: I) -> Vec<(i64, i32)> \n    where I : Iterator <Item = i32> {\n        let mut r = vec![(1, 0)];\n        let mut d = 0;\n        let mut p = 1;\n        for x in xs {\n            d = gcd(d as i64, x as i64) as i32;\n            p = lcm(p, x as i64);\n            r.push((p, d))\n        }\n        r\n}\n\nimpl Solution {\n    pub fn max_score(nums: Vec<i32>) -> i64 {\n        if nums.len() == 1 {\n            return nums[0] as i64 *nums[0] as i64 ;\n        } \n        if nums.len() == 2 {\n            let x = nums.into_iter().max().unwrap();\n            return x as i64 * x as i64 \n        }\n\n        let a = cum(nums.iter().cloned());\n        let b = cum(nums.iter().rev().cloned()).into_iter().rev().skip(1).collect::<Vec<(i64, i32)>>();\n        \n        let Some(&(p,d)) = a.last() else {panic!()};\n        let x = p * d as i64;\n\n        \n        a.into_iter().zip(b.into_iter()).map(|((p1, d1),(p2, d2))| lcm(p1,p2) * gcd(d1 as i64,d2 as i64)).max().unwrap().max(x)\n        \n    }\n}\n```
['Rust']