Language: C++

use std::vec::Vec;
use std::collections::HashMap;
use std::u128;


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

const MOD: usize = 1_000_000_000 + 7;
const MOD_128: u128 = 1_000_000_000 + 7;
fn main() {
    let n: usize = read();
    let a: Vec<u128> = read_vec();

    let mut l = a[0];
    for &e in &a {
      let g = gcd(l, e);
      l *= e;
      l /= g;
    }

    let mut ans = 0;
    for &e in &a {
      ans += l / e;
      ans %= MOD_128;
    }

    println!("{}", ans);
}

fn gcd(a: u128, b: u128) -> u128 {
  if b > a {
    gcd(b, a);
  }

  if a % b == 0 {
    return b;
  }

  let r: u128 = a % b;

  return gcd(b, r);
}


fn solve() {
    let n: usize = read();
    let a: Vec<usize> = read_vec();
    let mut map = HashMap::new();
    for &x in &a {
      let h = trial_division(x);
      for (key, val) in h.into_iter() {
        match map.get(&key) {
           Some(&v)  => {map.insert(key, if val > v { val } else { v });} ,
            _  => {map.insert(key, val);},
        }
      }
    }
    //println!("{:?}", map);
    let mut p: usize = 1;
    for (key, val) in map.into_iter() {
      p *= key.pow(val as u32);
      p %= MOD;
    }

    let mut ans = Mod::new_zero();
    for i in 0..n {
      ans = ans + Mod::new(p) / Mod::new(a[i]);
    }
    println!("{}", ans.unwrap());
}
// 試し割り
// O(√N)
fn trial_division(n :usize) -> HashMap<usize, usize>{
    let mut primes = HashMap::new();
    let mut i = 2;
    let mut n = n;

    //  n を root n 以下の整数で割り切れるまで割っていく
    while i * i <= n {
        while n % i == 0 {
            n /= i;
            // match primes.get_mut(&i) {
            //   None => { primes.insert(i, 1); },
            //   Some(x) => {
            //       *x += 1;
            //   },
            // }

            match primes.get(&i) {
              Some(&val) => {
                primes.insert(i, val + 1);
              },
              _  => { primes.insert(i, 1); },
            }
        }
        i+=1;
    }

    // 最後にnが素数になっている場合はそれ自身も素因数に含めて終了
    // match primes.get_mut(&n) {
    //   None => { primes.insert(n, 1); },
    //   Some(x) => {
    //     *x += 1;
    //   },
    // }

     match primes.get(&n) {
          Some(&val) => {
            primes.insert(n, val + 1);
          },
          _  => { primes.insert(n, 1); },
      }

    primes
}

use std::cmp::Ord;
use std::cmp::*;
use std::ops::Add;
use std::ops::Div;
use std::ops::Mul;
use std::ops::Neg;
use std::ops::Sub;

#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)]
struct Mod {
  val: usize,
}

// 和を定義
impl Add for Mod {
  type Output = Mod;
  // O(1)
  fn add(self, other: Mod) -> Mod {
    Mod {
      val: (self.val + other.val) % MOD,
    }
  }
}

// 差を定義
impl Sub for Mod {
  type Output = Mod;

  // O(1)
  fn sub(self, other: Mod) -> Mod {
    let mx = max(self.val, other.val);
    let mn = min(self.val, other.val);

    Mod {
      val: (mx - mn) % MOD,
    }
  }
}

// 積を定義
impl Mul for Mod {
  type Output = Mod;

  // O(1)
  fn mul(self, other: Mod) -> Mod {
    Mod {
      val: (self.val * other.val) % MOD,
    }
  }
}

// 加法単位元
impl Neg for Mod {
  type Output = Mod;

  // O(1)
  fn neg(self) -> Mod {
    Mod {
      val: MOD - self.val,
    }
  }
}

// 逆元を定義
// フェルマーの小定理により実装
impl Div for Mod {
  type Output = Mod;

  //O(logN)
  fn div(self, other: Mod) -> Mod {
    self * other.inv()
  }
}

impl Mod {
  // コンストラクター
  fn new(n: usize) -> Mod {
    Mod { val: n % MOD }
  }

  // 加法単位元
  fn new_zero() -> Mod {
    Mod { val: 0 }
  }

  // 乗法単位元
  fn new_one() -> Mod {
    Mod { val: 1 }
  }

  // 加法逆元
  // 上記にて定義

  // 乗法逆元
  fn inv(self) -> Mod {
    if self.val == 0 {
      panic!("zero divide");
    }
    self.pow(MOD - 2)
  }

  // 累乗を定義
  // O(logN)
  fn pow(self, n: usize) -> Mod {
    let mut res = 1;
    let mut a = self.unwrap();
    let mut n = n;

    while n > 0 {
      if n % 2 == 0 {
        a = a * a;
        n /= 2;
      } else {
        res = res * a;
        a = a * a;
        n /= 2;
      }
      res %= MOD;
      a %= MOD;
    }
    Mod::new(res)
  }

  // 最大公約数
  // O(logN)
  fn gcd(self, other: Mod) -> usize {
    let mut x = self.val;
    let mut y = other.val;
    while y != 0 {
      let t = y;
      y = x % y;
      x = t;
    }
    x
  }

  // 階乗
  // O(N)
  fn fact(self) -> Mod {
    let mut res = 1;
    for i in 1..self.val + 1 {
      res *= i;
      res %= MOD;
    }

    Mod::new(res)
  }

  // 順列
  fn perm(self, other: Mod) -> Mod {
    let mut res = Mod::new_one();
    for x in (self.val - other.val + 1)..self.val + 1 {
      res = res * Mod::new(x);
    }

    res
  }

  // 組み合わせ O(N)
  fn conb(self, other: Mod) -> Mod {
    if self < other {
      return Mod::new_zero();
    }
    self.fact() / (other.fact() * (self - other).fact())
  }

  // n C 0, n C 1, n C 2, ..., n C n を求める.
  fn conb_vec(self) -> Vec<usize> {
    let n: usize = self.unwrap();

    // 階乗のテーブル
    let mut table = vec![0; n + 1];
    // 逆元計算用テーブル
    let mut table_calc = vec![0; n + 1];
    // 逆元のテーブル
    let mut table_inv = vec![0; n + 1];

    // init
    table[0] = 1;
    table[1] = 1;
    table_calc[0] = 0;
    table_calc[1] = 1;
    table_inv[0] = 1;
    table_inv[1] = 1;

    for i in 2..n + 1 {
      table[i] = table[i - 1] * i % MOD;
      table_calc[i] = ((MOD - table_calc[MOD % i]) * (MOD / i)) % MOD;
      table_inv[i] = table_inv[i - 1] * table_calc[i] % MOD;
    }

    let mut res = Vec::new();
    for i in 0..n + 1 {
      res.push(((table[i] * table_inv[i]) % MOD) * table_inv[n - i] % MOD);
    }
    res
  }

  // 0 C k, 1C k, 2 C k, ..., n C k を求める.
  fn conb_vec2(self, k: usize) -> Vec<usize> {
    let n: usize = self.unwrap();

    // 階乗のテーブル
    let mut table = vec![0; n + 1];
    // 逆元計算用テーブル
    let mut table_calc = vec![0; n + 1];
    // 逆元のテーブル
    let mut table_inv = vec![0; n + 1];

    // init
    table[0] = 1;
    table[1] = 1;
    table_calc[0] = 0;
    table_calc[1] = 1;
    table_inv[0] = 1;
    table_inv[1] = 1;

    for i in 2..n + 1 {
      table[i] = table[i - 1] * i % MOD;
      table_calc[i] = ((MOD - table_calc[MOD % i]) * (MOD / i)) % MOD;
      table_inv[i] = table_inv[i - 1] * table_calc[i] % MOD;
    }

    let mut res = Vec::new();
    for i in 0..n + 1 {
      if i < k {
        res.push(0);
      } else {
        res.push(((table[i] * table_inv[k]) % MOD) * table_inv[i - k] % MOD);
      }
    }
    res
  }

  fn unwrap(self) -> usize {
    self.val % MOD
  }
}

Compiler output:
a.cc:80:14: error: too many decimal points in number
   80 |     for i in 0..n {
      |              ^~~~
a.cc:139:2: error: invalid preprocessing directive #[
  139 | #[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)]
      |  ^
a.cc:271:14: error: too many decimal points in number
  271 |     for i in 1..self.val + 1 {
      |              ^~~~~~~~~~~
a.cc:316:14: error: too many decimal points in number
  316 |     for i in 2..n + 1 {
      |              ^~~~
a.cc:323:14: error: too many decimal points in number
  323 |     for i in 0..n + 1 {
      |              ^~~~
a.cc:348:14: error: too many decimal points in number
  348 |     for i in 2..n + 1 {
      |              ^~~~
a.cc:355:14: error: too many decimal points in number
  355 |     for i in 0..n + 1 {
      |              ^~~~
a.cc:1:1: error: 'use' does not name a type
    1 | use std::vec::Vec;
      | ^~~
a.cc:2:1: error: 'use' does not name a type
    2 | use std::collections::HashMap;
      | ^~~
a.cc:3:1: error: 'use' does not name a type
    3 | use std::u128;
      | ^~~
a.cc:6:1: error: 'fn' does not name a type
    6 | fn read<T: std::str::FromStr>() -> T {
      | ^~
a.cc:12:1: error: 'fn' does not name a type
   12 | fn read_vec<T: std::str::FromStr>() -> Vec<T> {
      | ^~
a.cc:16:1: error: 'fn' does not name a type
   16 | fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
      | ^~
a.cc:22:10: error: found ':' in nested-name-specifier, expected '::'
   22 | const MOD: usize = 1_000_000_000 + 7;
      |          ^
      |          ::
a.cc:22:7: error: 'MOD' does not name a type
   22 | const MOD: usize = 1_000_000_000 + 7;
      |       ^~~
a.cc:23:14: error: found ':' in nested-name-specifier, expected '::'
   23 | const MOD_128: u128 = 1_000_000_000 + 7;
      |              ^
      |              ::
a.cc:23:7: error: 'MOD_128' does not name a type
   23 | const MOD_128: u128 = 1_000_000_000 + 7;
      |       ^~~~~~~
a.cc:24:1: error: 'fn' does not name a type
   24 | fn main() {
      | ^~
a.cc:44:1: error: 'fn' does not name a type
   44 | fn gcd(a: u128, b: u128) -> u128 {
      | ^~
a.cc:59:1: error: 'fn' does not name a type
   59 | fn solve() {
      | ^~
a.cc:87:1: error: 'fn' does not name a type
   87 | fn trial_division(n :usize) -> HashMap<usize, usize>{
      | ^~
a.cc:131:1: error: 'use' does not name a type
  131 | use std::cmp::Ord;
      | ^~~
a.cc:132:1: error: 'use' does not name a type
  132 | use std::cmp::*;
      | ^~~
a.cc:133:1: error: 'use' does not name a type
  133 | use std::ops::Add;
      | ^~~
a.cc:134:1: error: 'use' does not name a type
  134 | use std::ops::Div;
      | ^~~
a.cc:135:1: error: 'use' does not name a type
  135 | use std::ops::Mul;
      | ^~~
a.cc:136:1: error: 'use' does not name a type
  136 | use std::ops::Neg;
      | ^~~
a.cc:137:1: error: 'use' does not name a type
  137 | use std::ops::Sub;
      | ^~~
a.cc:141:3: error: 'val' does not name a type
  141 |   val: usize,
      |   ^~~
a.cc:145:6: error: expected initializer before 'Add'
  145 | impl Add for Mod {
      |      ^~~
a.cc:156:1: error: 'impl' does not name a type
  156 | impl Sub for Mod {
      | ^~~~
a.cc:171:1: error: 'impl' does not name a type
  171 | impl Mul for Mod {
      | ^~~~
a.cc:183:1: error: 'impl' does not name a type
  183 | impl Neg for Mod {
      | ^~~~
a.cc:196:1: error: 'impl' does not name a type
  196 | impl Div for Mod {
      | ^~~~
a.cc:205:1: error: 'impl' does not name a type
  205 | impl Mod {
      | ^~~~