Language: C++

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
const int MOD = 1e9+7;
long long modpow(long long x, long long n, long long m = 1e9+7) {
    if (n == 0) return 1;
    if (n % 2 == 1) return (x * modpow(x, n - 1, m)) % m;
    long long t = modpow(x, n / 2, m);
    return (t * t) % m;
}

unordered_set<long long> eratosthenes_sieve(int n) {
    vector<bool> v(n + 1, true);
    if (n >= 0) { v[0] = false; }
    if (n >= 1) { v[1] = false; }
    for (int i = 2; i*i <= n; i++) {
        if (!v[i]) { continue; }
        for (int j = i+i; j <= n; j += i) { v[j] = false; }
    }
    set<long long> ret;
    if (2 <= n) ret.insert(2);
    for (int i = 3; i < n; i++) if (v[i]) ret.insert(i);
    return ret;
}

map<long long, long long> prime_factor(long long n) {
  map<long long, long long> ret;
  for(long long i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      if (ret.count(i)) ret[i]++;
      else ret[i] = 1;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a/b; a -= t*b; swap(a, b); u -= t*v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if (e%2 == 0) { p = (p*p)%mod; e /= 2; }
            else { a = (a*p)%mod; e--; }
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

using mint = ModInt<MOD>;

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    unordered_set<long long> prime = eratosthenes_sieve((long long)1e6);
    //vector<map<long long, long long>> data(N);
    /*
    for (int i = 0; i < N; i++) data[i] = prime_factor(A[i]);
    
    map<long long, long long> L;
    for (auto e : prime) {
        long long res = 0;
        for (int i = 0; i < N; i++) {
            if (data[i].count(e)) chmax(res, data[i][e]);
        }
        if (res != 0) L[e] = res;
    }
    */
    auto LCM = [=](vector<long long> B)->mint {
        mint res = 1;
        for (auto e : prime) {
            long long a = 0;
            for (int i = 0; i < N; i++) {
                long long cnt = 0;
                while (B[i] % e == 0) {
                    B[i] /= e;
                    cnt++;
                }
                chmax(a, cnt);
            }
            if (a != 0) res *= modpow(e, a);
        }
        return res;
    };
    mint L = LCM(A);
    /*
    for (auto e : L) {
        long long a, b; tie(a, b) = e;
        long long res = modpow(a, b);
        LCM *= (mint)res;
    }
    */
    mint ans = 0;
    for (int i = 0; i < N; i++) {
        mint res = L;
        res /= (mint)A[i];
        ans += res;
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'std::__debug::unordered_set<long long int> eratosthenes_sieve(int)':
a.cc:26:12: error: could not convert 'ret' from 'std::__debug::set<long long int>' to 'std::__debug::unordered_set<long long int>'
   26 |     return ret;
      |            ^~~
      |            |
      |            std::__debug::set<long long int>